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

Re: Recordset for page count by Bob

Bob
Mon Apr 04 06:01:28 CDT 2005

tchangmian wrote:
> 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
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"