Paging Recordset - Almost There

Discussion in 'ASP General' started by Simon Harris, May 30, 2007.

  1. Simon Harris

    Simon Harris Guest

    Hi All,

    As you may have seen from my earlier post, I am trying to setup paging on an
    ASP application, I *think* this is 99% there.

    The only problem I have left, is when I get to the last page, I get the
    following error:
    ADODB.Field error '800a0bcd'
    Either BOF or EOF is True, or the current record has been deleted. Requested
    operation requires a current record.
    /myscript.asp, line 119 (See below for marker as to
    where 119 is)


    Now, I know the problem lies with my loop - Its looping from 1 to 20
    (rs.PageSize) even though the last page will have less records on it (Unless
    we are very lucky and the total number of records is always divisable by
    20!) I am just not sure what the Loop needs to be!

    Below is my code (Snipped to the relevent bits for ease of reading!)

    Any help will of course be appreciated!

    Cheers!
    Simon.


    // What page are we on?
    if (parseInt(Request.QueryString("Page")) > 0) {
    nPage = parseInt(Request.QueryString("Page"));
    } else {
    nPage = 1;
    }

    // Get data
    var rs= Server.CreateObject("ADODB.Recordset");
    rs.ActiveConnection = "dsn=TheData;";
    rs.Source = "SELECT * FROM customers;";
    rs.CursorLocation = 3;// adUseClient (Default locktype and cursortype)
    rs.PageSize = 20;
    rs.CacheSize = rsCartsCompleted.PageSize // Cache data - Not sure if this
    helps yet! Need to test!
    rs.Open();
    var rs_numRows = 0;
    nPageCount = rs.PageCount;
    rs.AbsolutePage = nPage;

    // Do the loop
    for (i=1;i<=rs.PageSize;i++) {
    // Display records...Line 119 is here, the first time I try to write out
    some data.
    rs.MoveNext();
    }

    --
    --
    * Please reply to group for the benefit of all
    * Found the answer to your own question? Post it!
    * Get a useful reply to one of your posts?...post an answer to another one
    * Search first, post later : http://www.google.co.uk/groups
    * Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!
     
    Simon Harris, May 30, 2007
    #1
    1. Advertisements

  2. Simon wrote on Wed, 30 May 2007 23:33:38 +0100:
    Check for EOF on the recordset after each MoveNext(), if it's true then
    break out of the loop.

    Dan
     
    Daniel Crichton, May 31, 2007
    #2
    1. Advertisements

  3. Simon Harris

    Simon Harris Guest

    Check for EOF on the recordset after each MoveNext(), if it's true then
    Dan - Great, working AOK now - Thank you!
     
    Simon Harris, May 31, 2007
    #3
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.