I use this solution (this is very simple example) for paging.
Maybe complicated (there are some improvements I know) but functional.
If any question, ask to me.
<%@ Language=VBScript %>
<%
Response.Buffer = True
Option Explicit
On Error Resume Next ' there's no testing for errors! You must do
yourself.
Dim rfPage, rfAction, intPage, bToPrev, bToNext, oConn, intPageSize,
orsRS, intCountPage, strRS, intTempCount, intPositionCursor
rfPage = Request("page")
rfAction = Trim(Request("action"))
If IsNull(rfPage) OR (rfPage = "") then
rfPage = 1
End If
If IsNumeric(rfPage) then
intPage = CLng(rfPage)
Else
intPage = 1
End If
' this moves to next or previous page
If rfAction = "<" then
intPage = intPage - 1
Elseif rfAction = ">" then
intPage = intPage + 1
End If
' If bToPrev = False then the button < is not showed
' and If bToNext = False then the button > is not showed
bToPrev = False
bToNext = False
Set oConn = CreateObject("ADODB.Connection")
oConn.Open Application("Conn_ConnectionString"),
Application("Conn_RuntimeUserName"), Application("Conn_RuntimePassword")
' Application("Conn_ConnectionString"), Application
' ("Conn_RuntimeUserName"), Application("Conn_RuntimePassword")
' are defined in global.asa
intPageSize = 50 ' Set your own page size = how many rows on page
sql = "SELECT ... FROM ..."
' or something like this just SQL command that selects the right rows
' If you have user definable varibles that are used in WHERE clause
' you must save it by <INPUT TYPE="HIDDEN" NAME="name" VALUE="">
' HTML tags and then read once more from Request.Form collection
Set orsRS = CreateObject("ADODB.RecordSet")
orsRS.Open sql, oConn, 3, 2
orsRS.PageSize = intPageSize
intCountPage = orsRS.PageCount ' count the pages for button > and <
(Next & Previous)
' Set the visibility of Next & Previous, > & < buttons
If intPage > 1 then
bToPrev = True
End If
If intCountPage > intPage then
bToNext = True
End If
strRS = ""
If NOT(orsRS.BOF AND orsRS.EOF) then
intTempCount = 1
If intPage > 1 then
intPositionCursor = intPageSize *(intPage - 1) + 1
orsRS.Move intPositionCursor
End If
Do while NOT(orsRS.EOF OR (intTempCount > intPageSize))
strRS = strRS & "" ' in this string I save the HTML rows from
SQL table... I.E.:
strRS = strRS & "<TR>"
strRS = strRS & "<TD WIDTH=600 COLSPAN=2 ALIGN=""CENTER"">" &
orsRS("column_name") & "</TD>"
strRS = strRS & "</TR>"
orsRS.MoveNext
intTempCount = intTempCount + 1
Loop
End If
orsRS.Close
Set orsRS = Nothing
oConn.Close
Set oConn = Nothing
%>
<HTML>
<BODY>
<FORM ACTION="this.asp" METHOD="POST"> ' replace this.asp with name of asp
file with this code
<INPUT TYPE="HIDDEN" NAME="page" VALUE=<%= intPage %>>
<TABLE WIDTH=600 BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD WIDTH=300 ALIGN="LEFT">
<% If bToPrev then %>
<INPUT type="submit" value=" < " NAME="action">
<% End If %>
</TD>
<TD WIDTH=300 ALIGN="RIGHT">
<% If bToNext then %>
<INPUT type="submit" value=" > " NAME="action">
<% End If %>
</TD>
</TR>
<%= strRS %>
<TR>
<TD WIDTH=300 ALIGN="LEFT">
<% If bToPrev then %>
<INPUT type="submit" value=" < " NAME="action">
<% End If %>
</TD>
<TD WIDTH=300 ALIGN="RIGHT">
<% If bToNext then %>
<INPUT type="submit" value=" > " NAME="action">
<% End If %>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<% Response.End %>
Regards,
Richard Bukovansky
richard.bukovansky@c...