I've some weird problem.. Someone pls help!
In some query, I can get the rst.PageCount, and in some other query, there is a result displayed on screen but the rst.PageCount returned -1.
This caused my " if rst.PageCount > 1 then" always return false.. Why is it so??!
<%
On Error Resume Next
Dim SQL,rst,ConnStr
Dim Page
Dim PageCounter
ConnStr = "Connection String here.."
'Get the Current page
Page = Request.QueryString("PageIndex")
'If there is no page set it to page 1
If Page = "" then Page = 1
RowCount = 0
SQL = ""
SQL = SQL + "Select statement here..."
set rst = Server.CreateObject("ADODB.Recordset")
'Need a rich cursor type to support paging
rst.CursorType = 3 'adOpenStatic
'Set the number of records in each page to 10
rst.PageSize = 10
'Open recordset
rst.Open SQL, ConnStr
'Set the current page based on the QueryString value
rst.AbsolutePage = cInt(Page)
%>
... some html statement here..
<%
if rst.PageCount > 1 then
Response.Write "Page " & Page & " of " & rst.PageCount & " "
Response.Write "[ "
'Write out links to switch between the pages.
'These just call this page again but with a querystring
'Page to determine the AbsolutePage to display.
For PageCounter = 1 to rst.PageCount
Response.Write "<a href='Result.asp?PageIndex=" & PageCounter & "'>" & PageCounter & "</a> "
Next
Response.Write " ]"
end if
%>
..Some other html statements..