%@ LANGUAGE="VBSCRIPT" %> <% Option Explicit %> <% 'Set how many records per page we want Const NumPerPage = 10 'Retrieve what page we're currently on Dim CurPage If Request.QueryString("CurPage") = "" then CurPage = 1 'We're on the first page Else CurPage = Request.QueryString("CurPage") End If Dim conn,strConn Set conn = Server.CreateObject("ADODB.Connection") strConn = "Provider=MICROSOFT.JET.OLEDB.4.0; " & "DATA SOURCE=" & Server.MapPath("database/test.mdb") conn.Open strConn 'Explicitly Create a recordset object Dim rs Set rs = Server.CreateObject("ADODB.Recordset") 'Set the cursor location property rs.CursorLocation = adUseClient 'Set the cache size = to the # of records/page rs.CacheSize = NumPerPage 'Open our recordset Dim strSQL strSQL = "SELECT First_Name,Last_Name FROM Clients ORDER BY Last_Name" rs.Open strSQL, Conn rs.MoveFirst rs.PageSize = NumPerPage 'Get the max number of pages Dim TotalPages TotalPages = rs.PageCount 'Set the absolute page rs.AbsolutePage = CurPage 'Counting variable for our recordset Dim count %>
First Name & Last Name
<%
'Set Count equal to zero
Count = 0
Do While Not rs.EOF And Count < rs.PageSize
Response.Write(rs("First_Name") & " " & rs("Last_Name") & "
")
Count = Count + 1
rs.MoveNext
Loop
'Print out the current page # / total pages
Response.Write("Page " & CurPage & " of " & TotalPages & "
") 'Display Next / Prev buttons if CurPage > 1 then 'We are not at the beginning, show the prev button Response.Write("") End If if CInt(CurPage) <> CInt(TotalPages) then 'We are not at the end, show a next button Response.Write("") End If %>