Multiple ADO database connection?

Hello, I am a newbe to programming. Is there a way to connect to multiple databases using ADO. I'm currently using the following string to connect to one database.

db_name1 = "FireReportingTest"
tablename1 = "FFD_Hydrant_Repairs_FD25"

db_name2 = "FRESNOFireRECORDSLIVE"
tablename2 = "hydrantactivity"

db_username = "fireprevention"
db_userpassword = "**"
fieldname = "Location"
fieldamount = Request("location")

connectstr1 = "Driver={SQL Server};SERVER=" & db_server & ";DATABASE=" & db_name1 & ";UID=" & db_username & ";PWD=" & db_userpassword
Set oConn1 = Server.CreateObject("ADODB.Connection")
oConn1.Open connectstr1

1 answer

You can have many connections open at the same time. You would just need to use separate variables for the other connections.

dbname1 = "FireReportingTest"
tablename1 = "FFDHydrantRepairsFD25"
dbname2 = "FRESNOFireRECORDSLIVE"
tablename2 = "hydrantactivity"
dbusername = "fireprevention"
dbuserpassword = "**"
fieldname = "Location"
fieldamount = Request("location")
connectstr1 = "Driver={SQL Server};SERVER=" & dbserver & ";DATABASE=" & dbname1 & ";UID=" & dbusername & ";PWD=" & dbuserpassword & ";"
connectstr2 = "Driver={SQL Server};SERVER=" & dbserver & ";DATABASE=" & dbname2 & ";UID=" & dbusername & ";PWD=" & dbuserpassword & ";"

Set oConn1 = Server.CreateObject("ADODB.Connection")
oConn1.Open connectstr1

Set oConn2 = Server.CreateObject("ADODB.Connection")
oConn2.Open connectstr2