Recordset for page count

T

tchangmian

I would like to ask how to return the recordset for page count. The
problem i faced is if it got 2 pages of results, it will display same
results for two page. For example, totally got 17 results, and we
choose 10 records per page, first page should display 10 results,and
2nd page display 7 results. But now first page can display 10 results,
but the 2nd page also display 10 results as 1st page. And when i
respons.write the page count, it return -1 and it suppose to return 2.
Below is my coding:




Set rstStoredProc = objCommand.Execute

if Request.QueryString("PageNum") = "" Then
intPageNum = 1
else
intPageNum = Request.QueryString("PageNum")
End if



Dim avarRecord


if(not rstStoredProc.EOF) Then


rstStoredProc.PageSize = intNumRecInPage

intPageCount = rstStoredProc.PageCount
if IntPageCount <= rstStoredProc.PageCount then
rstStoredProc.AbsolutePage = intPageNum
End If

avarRecord = rstStoredProc.GetRows

if Cint(UBound(avarRecord,2)) < CInt(intNumRecInPage) Then
intNumRecReturn = Cint(UBound(avarRecord,2))
Else
intNumRecReturn = CInt(intNumRecInPage) - 1
End If
 
B

Bob Barrows [MVP]

tchangmian said:
I would like to ask how to return the recordset for page count. The
problem i faced is if it got 2 pages of results, it will display same
results for two page. For example, totally got 17 results, and we
choose 10 records per page, first page should display 10 results,and
2nd page display 7 results. But now first page can display 10 results,
but the 2nd page also display 10 results as 1st page. And when i
respons.write the page count, it return -1 and it suppose to return 2.
Below is my coding:

The default cursor type is ForwardOnly, which supports neither pagecount nor
recordcount. To support these properties, you need a more expensive cursor:
either static, keyset or dynamic. Unless you set the Connection's CursorType
property before opening a recordset*, using set rs=cn.execute will cause you
to get a ForwardOnly cursor. To open a nondefault cursor, you must set the
recordset's cursortype property before opening it, and then use the
recordset's Open method to open it. See the documentation at
msdn.microsoft.com/library for specifics. Check out the recordset Open
method.

Having said that, I do not believe you should be using a more expensive
cursor type. There are other ways of determining which page you are on. You
are using a GetRows array, so you already have the capability of controlling
page sizes without opening a more expensive cursor. See:
http://www.aspfaq.com/show.asp?id=2120

Bob Barrows

* which will cause ALL recordsets to be opened with the non-default type you
set, a behavior which you may not want
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top