Need help with ADODB connection. Copying its value.
Posted on 2006-03-20
I just made a change to use cnn connection so I can open either MSAccess or mySql database.
I open a connection to MS Access database (cnADB).
Then I assign its value to another connection variable (Set cnn = cnADB)
Upon some user request, I open another connection to a mySql database (cnVC).
Because I want to start reading from mySql db instead of MS Access db (identical db layouts),
I close cnn connection (cnn.close, set cnn=nothing), then
assign cnVC to cnn (Set cnn=cnADB)
cnn is defined:
Dim cnn As New ADODB.Connection
cnADB and cnVC are defined in a module as public:
Public cnVC As New ADODB.Connection
Public cnADB As New ADODB.Connection
So far so good. Program mostly behaves well.
Where it goes wrong: When I go into another (child) form an try to open another table using cnADB connection, I get an error that says connection is either closed or invalid. (Of course, it worked fine, before I made changes to assign cnADB to cnn).
In debug, cnADB value still looks fine.
Any idea? Thanks.