Recordset for page count

Discussion in 'ASP General' started by tchangmian, Apr 4, 2005.

  1. tchangmian

    tchangmian Guest

    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
     
    tchangmian, Apr 4, 2005
    #1
    1. Advertising

  2. 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"
     
    Bob Barrows [MVP], Apr 4, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. efelnavarro09
    Replies:
    2
    Views:
    942
    efelnavarro09
    Jan 26, 2011
  2. Hung Huynh
    Replies:
    8
    Views:
    311
    Bob Barrows
    Sep 24, 2003
  3. Jack

    How can count RecordSet

    Jack, Jan 20, 2004, in forum: ASP General
    Replies:
    6
    Views:
    136
  4. Oscar
    Replies:
    27
    Views:
    481
    Mark J. McGinty
    Jun 1, 2005
  5. ifiaz
    Replies:
    1
    Views:
    936
    Martien Verbruggen
    Nov 19, 2003
Loading...

Share This Page