--- title: "AbsolutePage, PageCount, and PageSize Properties Example (JScript) | Microsoft Docs" ms.prod: sql ms.prod_service: connectivity ms.technology: connectivity ms.custom: "" ms.date: "01/19/2017" ms.reviewer: "" ms.topic: conceptual dev_langs: - "JScript" helpviewer_keywords: - "PageCount property [ADO], JScript example" - "AbsolutePage property [ADO], JScript example" - "PageSize property [ADO], JScript example" ms.assetid: 2db6dd3f-5a9c-438c-ae62-d09242906c98 author: MightyPen ms.author: genemi --- # AbsolutePage, PageCount, and PageSize Properties Example (JScript) This example demonstrates the AbsolutePage, PageCount and PageSize properties. Cut and paste the following code to Notepad or another text editor, and save it as **AbsolutePageJS.asp**. ``` <%@LANGUAGE="JScript" %> <%// use this meta tag instead of adojavas.inc%> AbsolutePage, PageSize, and PageSize Properties (JScript)

AbsolutePage, PageSize, and PageSize Properties (JScript)

<% // connection and recordset variables var Cnxn = Server.CreateObject("ADODB.Connection") var strCnxn = "Provider='sqloledb';Data Source=" + Request.ServerVariables("SERVER_NAME") + ";" + "Initial Catalog='Northwind';Integrated Security='SSPI';"; var rsEmployee = Server.CreateObject("ADODB.Recordset"); // display variables var strMessage, iRecord, iPageCount; try { // open connection Cnxn.Open(strCnxn); // Open a recordset on the Employee table using // a client-side cursor to enable AbsolutePage property. rsEmployee.CursorLocation = adUseClient; rsEmployee.Open("employees", strCnxn, adOpenStatic, adLockOptimistic, adCmdTable); // Set PageSize to five to display names and hire dates of five employees at a time rsEmployee.PageSize = 5; iPageCount = rsEmployee.PageCount; // Write header information to the document Response.Write('

There are ' + iPageCount); Response.Write(" pages, each containing "); Response.Write(rsEmployee.PageSize + " or fewer records.

"); Response.Write(''); Response.Write(''); Response.Write(""); for (var i=1; i<=iPageCount; i++) { rsEmployee.AbsolutePage = i; for (iRecord = 1; iRecord <= rsEmployee.PageSize; iRecord++) { strMessage = ""; // Start a new table row. strMessage = ''; // 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 += "" else strMessage += ""; // First and last name are in first column. strMessage += ""; // Hire date in second column. strMessage += ""; // End the row. strMessage += ""; // Write line to document. Response.Write(strMessage); // Get next record. rsEmployee.MoveNext; if (rsEmployee.EOF) break; } } // Finish writing table. Response.Write("
PageNameHire Date
Page " + i + " of " + rsEmployee.PageCount + " " + rsEmployee.Fields("FirstName") + " "; strMessage += rsEmployee.Fields("LastName") + " " + "" + rsEmployee.Fields("HireDate") + "
"); } catch (e) { Response.Write(e.message); } finally { // 'clean up if (rsEmployee.State == adStateOpen) rsEmployee.Close; if (Cnxn.State == adStateOpen) Cnxn.Close; rsEmployee = null; Cnxn = null; } %> ``` ## See Also [AbsolutePage Property (ADO)](../../../ado/reference/ado-api/absolutepage-property-ado.md) [PageCount Property (ADO)](../../../ado/reference/ado-api/pagecount-property-ado.md) [PageSize Property (ADO)](../../../ado/reference/ado-api/pagesize-property-ado.md) [Recordset Object (ADO)](../../../ado/reference/ado-api/recordset-object-ado.md)