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

EOF Alternative Question

Status
Not open for further replies.

jdyer

IS-IT--Management
Mar 24, 2003
53
US
I an looping through rows in a db to get log information. The log is getting long and do not want to list until EOF. How can I just list first 10 rows?

<%
Do until histinfo.EOF
%>
<tr>
<td><% = histinfo("uid") %>&nbsp; </td>
<td><% = histinfo("ppid") %>&nbsp;</td>
<td><% = histinfo("spid") %>&nbsp;</td>
<td><% = histinfo("date_field") %>&nbsp;</td>
</tr>
<%
histinfo.MoveNext
Loop
%>

Any help would be appreciated.

Thanks,
Jeff
 
You can limit the rs to 10 by saying

SELECT top 10 * FROM myTable


or

<%
x=10
Do until histinfo.EOF or x=10
x = x + 1
%>
<tr>
<td><% = histinfo("uid") %>&nbsp; </td>
<td><% = histinfo("ppid") %>&nbsp;</td>
<td><% = histinfo("spid") %>&nbsp;</td>
<td><% = histinfo("date_field") %>&nbsp;</td>
</tr>
<%
histinfo.MoveNext
Loop
%>


Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
You mean:

x=0
not
x=10

but great! thank you very much. I'm not sure why I couldn't of thought of that.

Jeff
 
You're definitely better off changing the SQL to "TOP 10", however -- the database still needs to select all of the records if you don't make the change, so the page is just going to get slower and slower every time. "TOP 10" will reduce that load considerably.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top