If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Recordset PageCount problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-13-04, 03:07
yinsw yinsw is offline
Registered User
 
Join Date: Sep 2003
Location: Penang, Malaysia
Posts: 9
Recordset PageCount problem

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..
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On