Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP with 2 databases (DSN) 1

Status
Not open for further replies.

pzom

Programmer
Oct 29, 2000
7
US
Hi,
I would like access 2 tables on diffrent DSN. This is my code which genereted error:

==================================================================================
dim oConn
dim strDB
strDB = "DSN=comparenew;"
set oConn=Server.CreateObject("ADODB.connection")
oConn.Open strDB
Response.Write &quot;Connection: &quot; & strDB & &quot;<br>&quot;
dim oRs
set oRs=Server.CreateObject(&quot;ADODB.recordset&quot;)
sqlText = &quot;Select * from SBC_MASTER_HEADER where line_no like ' A'&quot;
Ors.Open sqlText, oConn

dim oConn2
dim strDB2
strDB2 = &quot;DSN=compareold;&quot;
set oConn=Server.CreateObject(&quot;ADODB.connection&quot;)
oConn.Open strDB2
Response.Write &quot;Connection: &quot; & strDB2 & &quot;<br>&quot;
dim oRs2
set oRs2=Server.CreateObject(&quot;ADODB.recordset&quot;)
sqlText2 = &quot;Select * from SBC_MASTER_DETAIL where line_no <> ' A'&quot;
Ors2.Open sqlText2, oConn2
==================================================================================

This was the error generated on the last line:
----------------------------------------------------------------------------------
ADODB.Recordset error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
----------------------------------------------------------------------------------
Any help would be appreciated.

Thanks,
-Paul
 
You created the oConn Connection object twice. ------------------
Freedom is a Right
 
Goatstudio,

If I used the same connection for different DSN, I would get this error:

==========================================================
ADODB.Connection error '800a0e79'

Operation is not allowed when the object is open.

/perv1/sbcmst_master_as.asp, line 29
==========================================================

Do you think it is possible to have 2 DSN at the same time on one ASP page? If so can you give a sample snippet? Thanks.
 
What goatstudio tried to say was that you didn't reference your second connection in your second round of code:

dim oConn2
dim strDB2
strDB2 = &quot;DSN=compareold;&quot;
set oConn=Server.CreateObject(&quot;ADODB.connection&quot;)
oConn.Open strDB2
Response.Write &quot;Connection: &quot; & strDB2 & &quot;<br>&quot;
dim oRs2
set oRs2=Server.CreateObject(&quot;ADODB.recordset&quot;)
sqlText2 = &quot;Select * from SBC_MASTER_DETAIL where line_no <> ' A'&quot;
Ors2.Open sqlText2, oConn2

should be:

dim oConn2
dim strDB2
strDB2 = &quot;DSN=compareold;&quot;
set oConn2=Server.CreateObject(&quot;ADODB.connection&quot;)
oConn2.Open strDB2
Response.Write &quot;Connection: &quot; & strDB2 & &quot;<br>&quot;
dim oRs2
set oRs2=Server.CreateObject(&quot;ADODB.recordset&quot;)
sqlText2 = &quot;Select * from SBC_MASTER_DETAIL where line_no <> ' A'&quot;
Ors2.Open sqlText2, oConn2

only changed where you set oConn2 = server.....

and

oConn2.open

Should clear it up for you.
penny.gif
penny.gif
 
Thank you for the clarification.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top