Paging Recordset - Almost There
am 31.05.2007 00:33:38 von Simon HarrisHi 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!