<%
Set sqlConn = SERVER.CREATEOBJECT("ADODB.CONNECTION")
SET RS = SERVER.CREATEOBJECT("ADODB.RECORDSET")
' This will tell the recordset what page your on
Page = Request.QueryString("page")' Declare page number
If Page = "" Then
iPageCurrent = CInt(1)'If there is no page then page is 1
Else
iPageCurrent = CInt(Page)
End If
'Set the cursor type property of the record set to dynamic so we can naviagate through the record set
rs.CursorType = 1
'----------------------------------------------------------- ------
' Open your connection and recordset here
'----------------------------------------------------------- ------
'This will tell the recordset how many records to return
iPageSize = 10
'Get the total number of records in the recordset
iTotalRecords = RS.RecordCount ' Total # of records
'Define max number of records
RS.PageSize = iPageSize
'Get the total number of page in the recordset
iPageCount = RS.PageCount ' Total # of pages
'Move to the current page in the recordset
RS.AbsolutePage = iPageCurrent
'Counter to keep track of the number of records displayed
iRecordsShown = 0
'Loop thru records until Page Size is reached
Do While iRecordsShown < iPageSize AND Not RS.EOF
'----------------------------------------------------------- ------
' Output you recorset
' eg Response.Write RS("Record1")
'----------------------------------------------------------- ------
'increment counter
RS.MoveNext
iRecordsShown = iRecordsShown + 1
Loop
If iPageCurrent > 1 Then
Response.Write "<a href=""test.asp?page=" & iPageCurrent - 1 & """>Previous " & iPageSize & "</a>" & vbCrLf
End If
'Display a next link if needed
If iPageCount <> iPageCurrent Then
Response.Write "<a href=""test.asp?page=" & iPageCurrent + 1 & """>Next " & iPageSize & "</a>" & vbCrLf
End If
'Clean up
RS.Close
Set RS = Nothing
sqlConn.Close
Set sqlConn = Nothing
%>