multiple table connections

V

Vincent Jones

I have this:

<%
Dim objConn, RS, strQ, strConnection

Set objConn = Server.CreateObject("ADODB.Connection")
strConnection = "DSN=Development;Database=PMA_Internet;"
objConn.Open strConnection

Set RS = Server.CreateObject("ADODB.Recordset")
Set RS.ActiveConnection = objConn
strQ = "Select StaffName From tbStaff"
RS.Open strQ
%>

But I now want to connect to another table. Do I close the connection
and start over again to create 'strQ = "Select CorrectType from
Corrections'?
Thanks.
 
R

Ray at

You can use the same existing connection. Or, depending on what you're
doing, you may be able to grab all the data in one query. But, there's
nothing wrong with creating and using two recordsets within the same page.
I think that you should read this though.

http://www.aspfaq.com/show.asp?id=2424



Dim objConn, RS1, RS2, strQ, strConnection

strConnection = "It'd be in your best interests to use an oledb connection
string here. See www.connectionstrings.com"

Set objConn = CreateObject("ADODB.Connection")

strQ = "SELECT StaffName FROM tbStaff"
Set RS1 = objConn.Execute(strQ)

strQ = "SELECT CorrectType FROM Corrections"
Set RS2 = objConn.Execute(strQ)

'''stuff you need to do

objConn.Close : Set objConn = Nothing

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top