If you are coding the connection (not in the ADODC Object), the easiest (and the recommended in some books) way to do is making a connection "in fly" and closing and opening every time you need to:
Dim cn As New ADODB.Connection
Private Sub cmdConnect ()
If cn.State <> adStateClosed Then cn.Close
cn.Open "....(string connection"
End Sub
This will work every time the user press the Connect button.
If you are using an ADODC Object you only have to insert the connection string on the ADODC1.ConnectionString Property and refresh it
I hope this will help you
I'm using the ADODC Object.
setting it by ADODC1.ConnectionString = "connection string" doesn't work, because before I even get to this line it gives me an error (apparently untrappable, from the ADODC) about '"unknown" is not a valid path name...'. (I purposely made the connection string invalid until I set it for testing purposes) In other words, it's not letting me set the ConnectionString during run-time because I always get an error from it being invalid before I can set it...
Did your old connection string contain an invalid pathname? I want the application to be prepared for that situation; it seems to be the only thing causing the error, but I'll check for other things... Thanks....
As oneshadow says, you can change the ConnectionString at run-time. The way I've used this is by putting in any valid set of connection properties at design-time, and changing the properties at run-time to the ones I wanted. I found it best to confirm the ConnectionType property at run-time aswell.
"about '"unknown" is not a valid path name...'"
Basically, ADO is not finding your database. There could be a number of reasons for this, like a malformed string, or that the database has been moved.
Are you using a DSN or DSN-less connection, if DSN-Less, are you specifying the full path?
There are a lot of things that could be wrong, but I hope this points you in the right direction.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.