Maybe I've already answered this one but the best place to run the connection string is in a Form_Load sub procedure. Here's an example. If you want to reuse this connection string in other forms, it's best to create a global variable you can call from any module even if it's private. This example will be for Access.
Form_Load()
ADODC1.ConnectionString = "Microsoft.Jet.OLEDB.4.0.,Data Source = filename"
Make sure filename specifies the full file path including the directory and the database file name with extension.
The error I'm getting comes up before entering the Form_Load Procedure.... (I've had it come up right at the beginning of Form_Load, (before the first line of code), or even before that. I want to be able to assign it like so:
with form1
.ADODC1.ConnectionString = "connection string"
.ADODC1.Refresh
end with
The problem is, before I get to these lines, I get an error (unnumbered) because the current connection string is invalid (I purposely misspelled it before running, since it might have to be changed during runtime). The error says someting like
"(Unknown) is not a valid path. Make sure you have spelled the pathname correctly, and that you are connected to the server on which the file resides"
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.