|
-
January 27th, 2000, 11:35 AM
#1
ADO
How come I couldn't open it the second time?
THese are my code:
'I open the connection and myTable fisrt time:
With DataEnvironment1.cnnVendor
.ConnectionString = "Persist Security Info=False;User ID=Admin;" & _
"Data Source=" & MyDatabaseName & ";"
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Mode = adModeReadWrite
.Open
End With
DataEnvironment1.rsMyTable.Open
end with
'I close my connection and myTable:
DataEnvironment1.rsMyTable.close
DataEnvironment1.cnnVendor.close
'I open the connection and myTable second time (exactly the same code!!!)
With DataEnvironment1.cnnVendor
.ConnectionString = "Persist Security Info=False;User ID=Admin;" & _
"Data Source=" & MyDatabaseName & ";"
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Mode = adModeReadWrite
.Open
End With
DataEnvironment1.rsMyTable.Open
end with
---> but the last line "DataEnvironment1.rsMyTable.Open" bomb ???
The error say :"operation on an object with a reference to a closed or invalid Connection object."
Please help me out.
Thanks
-
January 27th, 2000, 12:02 PM
#2
Re: ADO
Kathy,
Are you looping through tables, or is this the exact same table object? If your looping through tables you might need to set the table object = Nothing after closing it, and then Set it again at the top of the loop.
Old school... six lines a day and I'm done.
-
January 27th, 2000, 01:18 PM
#3
Re: ADO
It's exacly the same table, and even if I set table record set to nothing,
still I've got the same error
-
January 27th, 2000, 05:20 PM
#4
Re: ADO
I've found code to help when you get the error you mentioned.
If DataEnvironment1.cnnVendor.State = adStateClosed then
DataEnvironment1.cnnVendor.Open
End If
-- Adding these few lines of code before you get the error should prevent your problem. This has worked for me and hopefully it helps your problem. If not then I'm sorry I don't know what to tell you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|