<%
Dim Connect_String
Dim Page_Size 'variable which holds the number of records to be viewed per page.
Dim Current_Page 'variable which keeps track of which page is the current page.
Dim MyConn
Dim RS
Dim SQL
Dim Page_Count 'variable which stores the number of pages that can be viewed.
Connect_String = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("testimonials.mdb")
Page_Size = 10 'here we set the number of records viewed per page to 15.
If Request("Page")="" Then
Current_Page = 1
Else
Current_Page = CInt(Request("Page")) 'the CInt function converts the value to an integer.
End If
Set MyConn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.RecordSet")
MyConn.Open Connect_String
RS.CursorLocation = adUseClient
RS.PageSize = Page_Size
SQL = "SELECT * FROM Testimonials WHERE Active=1"
RS.Open SQL, MyConn, adOpenStatic, adLockReadOnly, adCmdText
Page_Count = RS.PageCount
If 1 > Current_Page Then Current_Page = 1
If Current_Page > Page_Count Then Current_Page = Page_Count
RS.AbsolutePage = Current_Page
Do While RS.AbsolutePage = Current_Page AND Not RS.EOF
%>
<%=RS("First_Name") %>
<%= RS("Comments") %>
<%
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
MyConn.Close
Set MyConn = Nothing
Response.Write " "
If Current_Page <> 1 Then
Response.Write "Previous" & vbCrLf
Response.Write " " & vbCrLf
End If
If Current_Page < Page_Count Then
Response.Write "Next" & vbCrLf
End IF
%>
Click here if you would like to share your experience.