Scrollable Query

Overview

When you design application for an Internet environment, you will often want to limit the amount of information that a database query returns to a client browser. This example demonstrates how a script, using ASP and ADO, can limit the number of rows passed to the client browser in any one chunk, but still allow the user to browse through all the results of the query.

Code Tour

The script consists of several code sections that all work together to accomplish this task. First, the database is accessed as usual, creating a Connection object and Recordset object. The Recordset object's PageSize property is set to 4, and the recordset is opened and populated with the query results from the database table Authors. The first logical page of four result records are displayed in a table. Two buttons, PgUp and PgDn, are provided so that the user can view other pages of the recordset.

If a user clicks on a button, the page is accessed again, this time using the POST method to pass some variables to the next copy of itself. The variable PageNo is used to store what page the user is currently viewing, while the Mv variable is used to pass the scrolling direction to the next form. If a user clicks on PgDn, for instance, the page is accessed again, with Mv set to PgDn and PageNo set to 1. The script would use that information to add 1 to the current page number, and AbsolutePage could then be used to display the next page of results.

Important   OLE DB must be properly configured on the server for this sample to run properly.

Location

The VBScript and JScript versions of this script are available in the IIS samples directory, at ...\asp\database\MultiScrolling_VBScript.asp and ...\asp\database\MultiScrolling_JScript.asp.