[thelist] ADO cursor - best solution for count and page throughprocedure

Joshua Olson joshua at waetech.com
Wed Mar 31 07:52:37 CST 2004


> -----Original Message-----
> From: Adriano Castro
> Sent: Wednesday, March 31, 2004 6:58 AM
>
>     After reading (1) http://adopenstatic.com/faq/jetcursortypes.asp I
> asked myself which is the most appropriate cursor to use taking into
> consideration that before paging through a recordset I first want to
> count the number of entries on it.

Adiano,

For recordset pagination, I suggest *highly* that you look at the following
article:

http://www.15seconds.com/issue/010308.htm

It outlines a couple different approaches to working with paginated
recordsets.  Solution #3 uses none of the native ADO implementation to
facilitate paging and in my experience the method blows the doors off the
other methods.  It's fast, scalable, and very stable.

The only change that I would recommend to the approach (and this will make
sense once you read the article) is to only populate the temp table with the
PK and then do a join for the final select to get the page of results
instead of selecting all the fields in the initial population of the temp
table.

>     I don't want to create two recordsets (one for COUNT(*) and another
> one with the actual data) so I'm only using one.

For returning the count, I've found that returning count(*) in one of the
columns is a very viable option using the built in pagination methods.  In
the solution #3 mentioned above, you would perform a count(*) on the temp
table once it's populated.

>     Also, if all I want to do is check if the recordset returns anything
> is "IF (recordset.EOF) THEN do_something END IF" the best thing to do?

Generally you'd want to check that both EOF and BOF are true.

<><><><><><><><><><>
Joshua Olson
Web Application Engineer
WAE Tech Inc.
http://www.waetech.com/service_areas/
706.210.0168




More information about the thelist mailing list