I have two databases running off of the same site, and i need to use two global.asa's. since this is not possible, can I put both connections in one file? I did try just merging the two and that did not work, is there another way to do this? bb
I never use the global.asa for database connections. Instead I create a configuration include with seperate database logins. This way I can close the connections right after I pull my data and never have a problem. If your using and access or SQL database this will work. By creating a configuration include I can also use the same file for setting other parameters in my application by using a Virtual connection. I use mostly DSNLess connections and here's a sample.
<%
'---------------Create Common Data Path ---------------------------------------------
Dim DSNless
'Rem this is a DSNless connection for an access db
'
DSNless = "DRIVER={Microsoft Access Driver (*.mdb)};UID=(my user id);PWD=(my password);DBQ=(my hard path to database)D:\website\db\"
'
'------------- Connect to Database one------------------------------------------
'
Function OpenDB1 (ByRef Cn) 'Cn is the reference I pass to the function call
DSN = DSNless & "Database1.mdb"
Set Cn = Server.CreateObject("ADODB.Connection"
With Cn
.ConnectionString = DSN
.ConnectionTimeout = 15
.Open
End With
End Function
'
'------------- Connect to Database 2 ------------------------------------------
'
Function OpenDB2 (ByRef Cn)
DSN = DSNless & "Database2.mdb"
Set Cn = Server.CreateObject("ADODB.Connection"
With Cn
.ConnectionString = DSN
.ConnectionTimeout = 15
.Open
End With
End Function
'
'---- Repair Quotation Marks -----------------------------------------------------------
'
FUNCTION fixQuotes( theString )
fixQuotes = Replace( theString, "'", "''" )
END FUNCTION
%>
Remember though that even though I use Cn in both function calls you need to reference them differently on your page. Example :
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.