This question gets asked so many times here, I decided to put together a VBScript Class that will allow people to page a recordset. Here's the code and a page that will do it, just copy paste it into your favorite editor and start experimenting. You can definitely make the table prettier and should probably add some error handling. Anyway, happy coding!
[tt]
<%@ Language=VBScript %>
<% Option Explicit %>
<%
'include a reference to the ADO type library
'so we can use the ADO constants
%>
<!-- METADATA
TYPE="typelib"
FILE="C:\Program Files\Common Files\System\ADO\msado20.tlb"
-->
<%
Response.Buffer = True
Dim iCurrentPage
iCurrentPage = Request.QueryString ("pg"

If iCurrentPage = "" Then iCurrentPage = 1
Dim oPg
Set oPg = New DbPager
'Set public properties of the Pager Class
With oPg
[tab][tab].DataSource = "Provider=SQLOLEDB; Data_Source=(local); Initial Catalog=Northwind; User Id=sa; Password=;"
[tab][tab].RecsPerPage = 10
[tab][tab].SQL = "SELECT * FROM Customers ORDER BY CompanyName"
[tab][tab].ShowPageNumbers = True
[tab][tab].ShowPage (iCurrentPage)
End With
%>
<%
Class DbPager
[tab][tab]
'Set a few module level variables
[tab][tab]Private m_sDSN
[tab][tab]Private m_sSQL
[tab][tab]Private m_iRecsPerPage
[tab][tab]Private m_bShowPageNumbers
[tab][tab]
'datasource for the Data Page
[tab][tab]Public Property Let DataSource(NewValue)[tab]
'As String
[tab][tab][tab]m_sDSN = NewValue
[tab][tab]End Property
[tab][tab]
'sql statement to generate the page
[tab][tab]Public Property Let SQL(NewValue)[tab]
'As String
[tab][tab][tab]m_sSQL = NewValue
[tab][tab]End Property
[tab][tab]
'number of records you want per page
[tab][tab]Public Property Let RecsPerPage (NewValue)[tab]
'As Integer
[tab][tab][tab]m_iRecsPerPage = NewValue
[tab][tab]End Property
[tab][tab]
'Boolean to indicate whether or not to show all the page numbers
[tab][tab]Public Property Let ShowPageNumbers(NewValue)[tab]
'As Boolean
[tab][tab][tab]m_bShowPageNumbers = CBool(NewValue)
[tab][tab]End Property
[tab][tab]
'set default values
[tab][tab]Private Sub Class_Initialize()
[tab][tab][tab]ShowPageNumbers = True
[tab][tab][tab]m_iRecsPerPage = 10
[tab][tab]End Sub
[tab][tab]
'INPUT: Page you want to show
[tab][tab]'OUTPUT: Html
[tab][tab]Public Sub ShowPage (iCurrentPage)
[tab][tab][tab]Dim Rs
[tab][tab][tab]Set Rs = Server.CreateObject ("ADODB.Recordset"
[tab][tab][tab]With Rs
[tab][tab][tab][tab].CacheSize = m_iRecsPerPage
[tab][tab][tab][tab].PageSize = m_iRecsPerPage[tab]
'# of records / page
[tab][tab][tab][tab].CursorLocation = adUseClient
[tab][tab][tab][tab]
'Absolute Page requires Keyset or Static cursor
[tab][tab][tab][tab].CursorType = adOpenKeyset
[tab][tab][tab][tab].Open m_sSQL, m_sDsn
[tab][tab][tab][tab].AbsolutePage = iCurrentPage[tab]
'Set the page
[tab][tab][tab]End With
[tab][tab][tab]
'Number of fields, number of pages
[tab][tab][tab]Dim iNumFields, iNumPages
[tab][tab][tab]iNumFields = Rs.Fields.Count
[tab][tab][tab]iNumPages = Rs.PageCount
[tab][tab][tab]Dim i, iFld, iRec
[tab][tab][tab]Response.Write "<TABLE Border=1 Width='100%'>"
[tab][tab][tab]
'a routine to write the page navigation
[tab][tab][tab]WriteNavigation iCurrentPage, iNumPages, iNumFields
[tab][tab][tab]
'Write all the field names
[tab][tab][tab]'as column headings
[tab][tab][tab]Response.Write "<TR>"
[tab][tab][tab]For iFld = 0 To iNumFields - 1
[tab][tab][tab][tab]Response.Write "<TD>" & Rs.Fields(iFld).Name & "</TD>"
[tab][tab][tab]Next
[tab][tab][tab]Response.Write "<TR>"
[tab][tab][tab]
'Write the cell values
[tab][tab][tab]For i = 1 To m_iRecsPerPage
[tab][tab][tab][tab]If Rs.EOF Then Exit For
[tab][tab][tab][tab]Response.Write "<TR>"
[tab][tab][tab][tab]For iFld = 0 To iNumFields - 1
[tab][tab][tab][tab][tab]Response.Write "<TD>" & Rs.Fields(iFld).Value & "</TD>"
[tab][tab][tab][tab]Next
[tab][tab][tab][tab]Response.Write "</TR>"
[tab][tab][tab][tab]Rs.MoveNext
[tab][tab][tab]Next
[tab][tab][tab]Response.Write "</TABLE>"
[tab][tab]End Sub
[tab][tab]
'INPUT: Current Page, Number of total pages, number of fields
[tab][tab]'OUTPUT: Html for navigating the recordset
[tab][tab]Private Sub WriteNavigation(iCurrentPage, iNumPages, iNumFields)
[tab][tab][tab]Dim i, sScriptName
[tab][tab][tab]sScriptName = Request.ServerVariables ("SCRIPT_NAME"
[tab][tab][tab]iCurrentPage = CInt(iCurrentPage)
[tab][tab][tab]Dim iPreviousPage, iNextPage
[tab][tab][tab]
'at the first page so set the previous page to the last page
[tab][tab][tab]If iCurrentPage = 1 Then
[tab][tab][tab][tab]iPreviousPage = iNumPages
[tab][tab][tab]Else
[tab][tab][tab][tab]iPreviousPage = iCurrentPage - 1
[tab][tab][tab]End If
[tab][tab][tab]
'at the last page so set the next page to the first page
[tab][tab][tab]If iCurrentPage = iNumPages Then
[tab][tab][tab][tab]iNextPage = 1
[tab][tab][tab]Else
[tab][tab][tab][tab]iNextPage = iCurrentPage + 1
[tab][tab][tab]End If
[tab][tab][tab]Response.Write "<TR>"
[tab][tab][tab]Response.Write "<TD Colspan='" & iNumFields & "' Align=Center>"
[tab][tab][tab]
'previous page
[tab][tab][tab]Response.Write "<A HREF='" & sScriptName & "?pg=" & iPreviousPage & "'>Prev</A> "
[tab][tab][tab]
'if show all page numbers (clickable)
[tab][tab][tab]'this can get out of hand with big recordsets
[tab][tab][tab]If m_bShowPageNumbers Then
[tab][tab][tab][tab]For i = 1 To iNumPages
[tab][tab][tab][tab][tab]If i = iCurrentPage Then
[tab][tab][tab][tab][tab][tab]Response.Write "<B>" & i & "</B>"
[tab][tab][tab][tab][tab]Else
[tab][tab][tab][tab][tab][tab]Response.Write "<A HREF='" & Request.Servervariables("SCRIPT_NAME"

& "?pg=" & i & "'>"
[tab][tab][tab][tab][tab][tab]Response.Write i & "</A>"
[tab][tab][tab][tab][tab]End If
[tab][tab][tab][tab][tab]Response.Write " "
[tab][tab][tab][tab]Next
[tab][tab][tab]End If
[tab][tab][tab]
'next page navigation
[tab][tab][tab]Response.Write " <A HREF='" & sScriptName & "?pg=" & iNextPage & "'>Next</A>"
[tab][tab][tab]Response.Write "</TD>"
[tab][tab][tab]Response.Write "</TR>"
[tab][tab]End Sub
End Class
%>
[/tt]