Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Recordset for page count

Reply
Thread Tools

Recordset for page count

 
 
tchangmian
Guest
Posts: n/a
 
      04-04-2005
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
 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      04-04-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"


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing Recordset from an ASP page to another HTML page ? Oscar ASP General 27 06-01-2005 04:24 PM
Count(*) in a Subquery with multiple tables: How does SQL determine which table to generate the Count() from? Kaimuri MCSD 3 12-29-2004 06:38 PM
I am adding a new row to the datagrid dynamically but if i use the Count property of Item it is not showing the count of the new rows being added Praveen Balanagendra via .NET 247 ASP .Net 2 06-06-2004 07:16 AM
How can count RecordSet Jack ASP General 6 01-20-2004 11:46 PM
RecordSet.Move or RecordSet.AbsolutePosition?? Hung Huynh ASP General 8 09-24-2003 11:07 AM



Advertisments