RcrdSet.MoveLast

Discussion in 'ASP General' started by le0, Aug 24, 2006.

  1. le0

    le0 Guest

    Hello guys,

    I have this little problem in query, i queried one table and sort this
    record in descending order but when I declared the recordset to move in the
    last record but the browser rerurns an error called "Rowset does not support
    fetching backward", but when I set the record to move in the first record
    the browser returns the value I want. What does the error means?

    code:

    rstTSAnalysis.MoveLast
    intItem = int(rstTSAnalysis.Fields("ItemNo").Value)

    Response.Write intItem

    Leo :)
     
    le0, Aug 24, 2006
    #1
    1. Advertising

  2. le0

    Bobbo Guest

    le0 wrote:

    > I have this little problem in query, i queried one table and sort this
    > record in descending order


    Can you not change the underlying SQL query instead? Your database is
    probably more efficient at sorting a recordset than ASP.
     
    Bobbo, Aug 24, 2006
    #2
    1. Advertising

  3. le0 wrote:
    > Hello guys,
    >
    > I have this little problem in query, i queried one table and sort this
    > record in descending order but when I declared the recordset to move
    > in the last record but the browser rerurns an error called "Rowset
    > does not support fetching backward", but when I set the record to
    > move in the first record the browser returns the value I want. What
    > does the error means?
    > code:
    >
    > rstTSAnalysis.MoveLast
    > intItem = int(rstTSAnalysis.Fields("ItemNo").Value)
    >
    > Response.Write intItem
    >

    The problem is likely to be caused by the code you did not show us: cursor
    type has a great deal to do with whether or not commands like MoveLast,
    FoveFirst, etc. can work. The technique used to open your recordset has a
    great deal to do with the cursor type used. The default cursor type is
    forward-only: if you open a server-side (default - this cursor location is
    specified by the constant adUseServer) recordset without specifying a cursor
    type, you will get a forward-only cursor. If you specify adUseClient
    (client-side cursor) for the recordset's CursorLocation property, you will
    always get a static cursor (adOpenStatic), regardless of which type you may
    have specified for the CursorType. Unless you specify these properties at
    the Connection level (the Connection object has these properties as well as
    the recordset), using Execute to open a recordset will result in the default
    server-side, forward-only cursor.

    Depending on the Provider being used, support for these navigational
    commands can vary. Some providers will not suppport any navigation beyond
    MoveNext if a default forward-only cursor is used. If you really require the
    extra navigational commands (and I am not convinced that you do - it seems
    to me a GetRows array would server your purposes handily), then you need
    most likely need to use a more expensive static cursor (at the least). You
    can guarantee that you get a static cursor by instantiating a recordset
    object, setting its CursorLocation to adUseClient (3), and using its Open
    method to open it, rather than using Execute.

    The ADO documentation (as well as documentation for all MS development
    technologies) can be found here:
    http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoapireference.asp
    I suggest you go there and _study_ the topics I discussed.

    Help with GetRows can be found here:
    http://www.aspfaq.com/search.asp?q=GetRows&type=ALL&category=0&numDays=0&order=1



    --
    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], Aug 24, 2006
    #3
    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. Marcin Zmyslowski

    MoveFirst, MoveLast

    Marcin Zmyslowski, Aug 18, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    5,823
    Cathal Connolly [VB MVP]
    Aug 18, 2005
  2. joeandtel

    Can't use moveLast() function

    joeandtel, Feb 20, 2004, in forum: ASP General
    Replies:
    1
    Views:
    114
    Ray at
    Feb 20, 2004
  3. tony wong

    Recordset MoveLast

    tony wong, Aug 14, 2005, in forum: ASP General
    Replies:
    3
    Views:
    151
    Aaron Bertrand [SQL Server MVP]
    Aug 15, 2005
Loading...

Share This Page