displaying db results with asp

M

matt shudy

Hi,

I am using a
Do While Not objRS.EOF loop,
after that has completed is it at the end of the file?...
meaning that you can't call that same loop again? I want
to make three different tables using the same db record,
so i just use an if statementin the while loop to pull out
the records that i want, but then the next table won't
populate. Is there a way to reset the loop so it starts
at the top of the file again? Please let me know if you
need this explaied different.

Thanks,

Matt Shudy
 
J

jon spivey

Hi Matt,

You can start over with oRs.movefirst. In general tho getrows is a much more
efficient way to loop thru a recordset. Eg -
<%
set oRs = server.createobject("adodb.recordset")
ors.open "select field from table", 'connection string
aData = oRs.getrows
oRs.close: set oRs=nothing
for i = 0 to ubound(aData,2)
response.write aData(0,i) & "<BR>"
next
' we can then start again by repeating the loop
for i = 0 to ubound(aData,2)
response.write aData(0,i) & "<BR>"
next
%>
 
G

Guest

Thank you, this helped a lot.

Matt
-----Original Message-----
Hi Matt,

You can start over with oRs.movefirst. In general tho getrows is a much more
efficient way to loop thru a recordset. Eg -
<%
set oRs = server.createobject("adodb.recordset")
ors.open "select field from table", 'connection string
aData = oRs.getrows
oRs.close: set oRs=nothing
for i = 0 to ubound(aData,2)
response.write aData(0,i) & "<BR>"
next
' we can then start again by repeating the loop
for i = 0 to ubound(aData,2)
response.write aData(0,i) & "<BR>"
next
%>

--
Jon
Microsoft MVP - FP




.
 
Top