July 17th, 2004, 11:04 AM
Join Date: Jul 2004
Time spent in forums: < 1 sec
Reputation Power: 0
Visual Basic, DB access, problem.
Hello. I've contact with Visual Basic Only for couple of days and have a big problem.
First I'vegot wellknow "Operation is not allowed when the object is closed" error problem
but i've read somewhere that i should delete my Set before rs = cn.Execute (sQuery, ,adCmdText)
and it worked, the value 45 is inserted into my DB Column, but now ive got another error in this line
(10094) ActiveX Automation: Object var is 'Nothing'. I dont know what to do ive spend many hours
on this without success. If someone could help me Ill be very greatfull.
Im sending u my code:
Dim cn As Object
Dim rs As New ADODB.Recordset
Dim sQuery As String
' Open the connection to MyDB database
Set cn = GetDataLoggerADOConn("MyDB")
sQuery = "insert into MyTable" & _
"(MyCol1)" & _
' Open the recordset and caluclate the average, min or max value
rs = cn.Execute (sQuery, ,adCmdText)
If Not rs.EOF Then
MyCol1_Calc = rs.Fields("Average1").Value
MyCol2_Calc = rs.Fields("Average2").Value
MyCol1_Calc = 0
MyCol2_Calc = 0
MsgBox GetStringFromID("ID_ErrNoData"), vbOkOnly + vbInformation, "MOVICON"
Set rs = Nothing
Set cn = Nothing
i think sth usefull may be on this link http://www.biglist.com/lists/xsl-list/archives/200105/msg01272.html
but i dont have enough knowledge to modify my code myself.
If someone could modyfi my code ill be very greatfull