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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Recordsets - More than one open at a time??

Status
Not open for further replies.

webIntern

Programmer
Nov 22, 2002
40
US
Is it possible to either:
1)Have more than one recordset open at once? All recordsets from the same database, but independent of each other

Or

1)Just create one recordset object, open - close - and recreate multiple times?

 
I think you explained it to yourself. just instantiate multiple recordset objects.
 
you can have multiple recordsets opened at anytime

objRS1.open
objRS2.open
objRSN.open
 
Ok, so which would be more efficient? Does it make a difference in processing time or workload?

 
webintern,

I believe the difference is negligible when it comes to processing time. But what I think matters is how difficult it could be to debug your ASP code whenever you try to use a single recordset object on different tables in your database.

Medic
 
Ok...another question - btw thanks to all for your help

Now, if I want to use the same recordset object - re open it with a different query each time...do I need to set it to nothing before re-opening it?? I know I need to at least close it first...but something still isn't working. Every time I try to run the code the page gets "stuck", it won't finish loading.

Here's the relevant portion of my code:

<%
Dim rs
Set rs = Server.CreateObject(&quot;ADODB.RecordSet&quot;)
Dim strItem
sSqlString = &quot;SELECT * FROM itemlist WHERE category = 'apparel'&quot;
rs.Open sSqlString, oConnection, 0

Do While NOT rs.EOF
strItem = rs(&quot;item&quot;)
%>
<option><%=strItem%></option>
<%
rs.MoveNext
Loop
rs.Close
%>
...some more html, then:

<%
sSqlString = &quot;SELECT * FROM itemlist WHERE category = 'miscellaneous'&quot;
rs.Open sSqlString, oConnection, 0

Do While NOT rs.EOF
strItem = rs(&quot;item&quot;)
%>
<option><%=strItem%></option>
<%
Loop
rs.MoveNext
rs.Close
%>

 
Your last rs.MoveNext command is placed outside the Do While ...Loop. You should place it inside the loop.

Medic
 
And yes, setting it to Nothing would be good. I have seen some extremely strange results occur occasionally when not setting it to nothing. Like no results at all :p

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top