Paging Recordset - Almost There

S

Simon Harris

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!
 
D

Daniel Crichton

Simon wrote on Wed, 30 May 2007 23:33:38 +0100:
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)
// 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();
}

Check for EOF on the recordset after each MoveNext(), if it's true then
break out of the loop.

Dan
 

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

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top