This example demonstrates the AbsolutePage, PageCount and PageSize properties.
<!-- BeginAbsolutePageJS --> <% @LANGUAGE="JScript" %> <!-- Include file for JScript ADO Constants --> <!--#include File="adojavas.inc"--> <html> <head> <title>AbsolutePage, PageSize, and PageSize Properties (JScript)</title> <style> <!-- BODY { font-family: 'Verdana','Arial','Helvetica',sans-serif; BACKGROUND-COLOR:white; COLOR:black; } .thead2 { background-color: #800000; font-family: 'Verdana','Arial','Helvetica',sans-serif; font-size: x-small; color: white; } .tbody { text-align: center; background-color: #f7efde; font-family: 'Verdana','Arial','Helvetica',sans-serif; font-size: x-small; } --> </style> </head> <body bgcolor="White"> <h1>AbsolutePage, PageSize, and PageSize Properties (JScript)</h1> <% // Open the connection. var Connect = "Provider=sqloledb;Data Source=" + Request.ServerVariables("SERVER_NAME")+ ";" + "Initial Catalog=Northwind;User Id=sa;Password=;" // Open a recordset on the Employee table using // a client-side cursor to enable AbsolutePage property. var RsEmployee = Server.CreateObject("ADODB.Recordset"); RsEmployee.CursorLocation = adUseClient; RsEmployee.Open("employees", Connect, adOpenStatic, adLockOptimistic, adCmdTable); // Set PageSize to five, so we can display names // and hire dates, five employees at a time. RsEmployee.PageSize = 5; // strMessage is used to build up each row of // the table before writing to document. var strMessage; var iPageCount = RsEmployee.PageCount; var iRecord; // Write header information to the document. Response.Write('<p align="center">There are ' + iPageCount); Response.Write(" pages, each containing "); Response.Write(RsEmployee.PageSize + " records.</p>"); Response.Write('<table border="0" align="center">'); Response.Write('<tr class="thead2">'); Response.Write("<th>Page</th><th>Name</th><th>Hire Date</th></tr>"); for (var i=1; i<=iPageCount; i++) { RsEmployee.AbsolutePage = i; for (iRecord=1; iRecord <= RsEmployee.PageSize; iRecord++) { strMessage = ""; // Start a new table row. strMessage = '<tr class="tbody">'; // First column in row contains page number on // first record of each page. Otherwise, the column // contains a non-breaking space. if (iRecord == 1) strMessage += "<td>Page " + i + " of " + RsEmployee.PageCount + "</td>" else strMessage += "<td> </td>"; // First and last name are in first column. strMessage += "<TD>" + RsEmployee.Fields("FirstName") + " "; strMessage += RsEmployee.Fields("LastName") + " " + "</td>"; // Hire date in second column. strMessage += "<td>" + RsEmployee.Fields("HireDate") + "</td>"; // End the row. strMessage += "</tr>"; // Write line to document. Response.Write(strMessage); // Get next record. RsEmployee.MoveNext; if (RsEmployee.EOF) break; } } // Finish writing table. Response.Write("</table>"); // Close table. RsEmployee.Close; %> </body> </html> <!-- EndAbsolutePageJS -->
AbsolutePage Property | PageCount Property | PageSize Property | Recordset Object