Can't have 2 connection objects?
I have this in my declarations:
VB Code:
Public CN As ADODB.Connection
Public RS As ADODB.Recordset
I've used this code before, but only with 1 connection. I open the connection like this:
VB Code:
Set CN = New ADODB.Connection
CN.Provider = "Provider=SQLOLEDB.1;Password=xxxx;Persist Security Info=True;User ID=labuser;Initial Catalog=Nonconf;Data Source=myserver"
CN.Open
My problem is, I have to open a connection to a different database while this connection is open. So I copied the declarations of the CN and RS objects and added a "2" after each. Now it won't even open the first connection claiming "Provider not found, It may not be installed". If I remove the declaration of the second connection object, it works fine. I cannot reuse the same connection on 2 different databases can I?
What am I doing wrong? Why won't it allow me to have 2 connection objects?
Using: VB6, SP5 w/ ADO and SQL Server 2K
Re: Can't have 2 connection objects?
Quote:
Originally posted by ober0330
I have this in my declarations:
VB Code:
Public CN As ADODB.Connection
Public RS As ADODB.Recordset
I've used this code before, but only with 1 connection. I open the connection like this:
VB Code:
Set CN = New ADODB.Connection
CN.[b]Provider [/b]= "Provider=SQLOLEDB.1;Password=xxxx;Persist Security Info=True;User ID=labuser;Initial Catalog=Nonconf;Data Source=myserver"
CN.Open
My problem is, I have to open a connection to a different database while this connection is open. So I copied the declarations of the CN and RS objects and added a "2" after each. Now it won't even open the first connection claiming "Provider not found, It may not be installed". If I remove the declaration of the second connection object, it works fine. I cannot reuse the same connection on 2 different databases can I?
What am I doing wrong? Why won't it allow me to have 2 connection objects?
Using: VB6, SP5 w/ ADO and SQL Server 2K
You have got it all cocked up. Try setting that as the ConnectionString intead of the Provider.
TG