<%
' Get parameters
iPageSize = 9 ' You could easily allow users to change this
' Retrieve page to show or default to 1
If Request("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request("page"))
End If
strSQL = "select * from tblAlbum ORDER BY fldDate DESC"
Set objPagingConn = Server.CreateObject("ADODB.Connection")
objPagingConn.Open strConn
Set objPagingRS = Server.CreateObject("ADODB.Recordset")
objPagingRS.PageSize = iPageSize
objPagingRS.CacheSize = iPageSize
objPagingRS.Open strSQL, objPagingConn, adOpenStatic, adLockReadOnly, adCmdText
iPageCount = objPagingRS.PageCount
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1
If iPageCount = 0 Then
%>
There is no album stored
in the database. Please come back later.
<%
else
objPagingRS.AbsolutePage = iPageCurrent
' Loop through our records and ouput 1 row per record
iRecordsShown = 0
Do While iRecordsShown < iPageSize And Not objPagingRS.EOF
%>
<%
' Increment the number of records we've shown
iRecordsShown = iRecordsShown + 1
' Can't forget to move to the next record!
objPagingRS.MoveNext
Loop
' END RUNTIME CODE
End If
objPagingRS.Close
Set objPagingRS = Nothing
objPagingConn.Close
Set objPagingConn = Nothing
%>
Page
<%= iPageCurrent %> of <%= iPageCount %>
<% If iPageCurrent <> 1 Then %>
<% end if
if iPageCurrent < iPageCount Then %>
<% End If %>