Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Simple Loop Question
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Lycaster
New Member

USA
60 Posts

Posted - 02 May 2001 :  13:33:39  Show Profile  Visit Lycaster's Homepage  Send Lycaster an AOL message
I have a loop that shows all my records. Now I need to know how to have it
only bring back 5 or 10 records at a time.

here is my loop code:

If Not rs.EOF Then
Do Until rs.EOF

' Stuff I am looping here

rs.MoveNext
Loop
End If

Thanks for the help!

- Jared



HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 02 May 2001 :  13:37:15  Show Profile  Visit HuwR's Homepage

If Not rs.EOF Then
counter = 1
Do Until rs.EOF or counter = 5

' Stuff I am looping here

rs.MoveNext
counter = counter + 1
Loop
End If



Go to Top of Page

work mule
Senior Member

USA
1358 Posts

Posted - 03 May 2001 :  10:07:39  Show Profile
quote:

I have a loop that shows all my records. Now I need to know how to have it
only bring back 5 or 10 records at a time.



Depending on your database, another option would be to use "SELECT TOP x" to limit the number of records returned. If your SQL statement would return 100+ records and you know you only need 5 or 10, then your database server doesn't have to do additional work by returning all the records - plus then it's more efficient on the asp side because you don't have to do additional programming to step through and count each record.

Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 03 May 2001 :  15:03:58  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
or check out this page...

http://www.freeaspcode.net/freeaspcode/code/asp/segments/code/access_database_paging.asp?pg=1

Brad
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 03 May 2001 :  15:48:04  Show Profile  Visit HuwR's Homepage
quote:

quote:

I have a loop that shows all my records. Now I need to know how to have it
only bring back 5 or 10 records at a time.



Depending on your database, another option would be to use "SELECT TOP x" to limit the number of records returned. If your SQL statement would return 100+ records and you know you only need 5 or 10, then your database server doesn't have to do additional work by returning all the records - plus then it's more efficient on the asp side because you don't have to do additional programming to step through and count each record.





This would depend wether you had an order by in your query, since the dataset is ordered before doing the TOP x

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.26 seconds. Powered By: Snitz Forums 2000 Version 3.4.07