How can I page database results N records at a time? [Print this FAQ]
Answer:
Displaying information from a database table can be a science onto itself, especially as the sheer amount of information in a table grows. For example, imagine that you had a database table that contained 10,000 rows. If you wanted to display this information, simply listing all 10,000 rows on a single Web page would be unplausable - it would consume gobs of resources and would be far too much information to be useful for the visitor.
To overcome this problem, many developers "page" database table results. For example, instead of displaying all 10,000 rows, a developer might choose to display 20 rows per Web page. Each page would have Next and Previous links so the user could step through the data in digestible chunks.
Thankfully, ADO provides a method to accomplish this. There are three ADO properties - PageSize, AbsolutePage, and PageCount - that can be used to page results from any data store. A complete, working example of paging database results using these properties can be seen at: Paged Table Displays.
Another option for paging is to use stored procedures. The only drawback to this approach is that you must be using SQL Server as your data store. To learn more about this approach, be sure to read: Paging Through Records Using a Stored Procedure.
Do you have a FAQ you'd like to suggest?
Suggestions? Comments? If so, send it in!
Also, if you'd like to be a FAQ Admin (creating/editing FAQs),
let me know! If you are looking for other FAQs, be
sure to check out the 4Guys
FAQ and Commonly Asked Messageboard Questions!