DAO Recordcount vs. ADO Recordcount

DAO Recordcount vs. ADO Recordcount

Post by Michel Vanderbek » Fri, 10 Dec 1999 04:00:00



In DAO, to get a correct Recordcount, you had to do a movelast and a
movefirst of the recordset before you could use the recordcount.

Is this also necessary in ADO?

Many thanks and greetings from Brugge (Bruges - Belgium),

Michel

 
 
 

DAO Recordcount vs. ADO Recordcount

Post by Curtis Spendlo » Fri, 10 Dec 1999 04:00:00


Quote:>In DAO, to get a correct Recordcount, you had to do a movelast and a
>movefirst of the recordset before you could use the recordcount.
>Is this also necessary in ADO?

Don't take this as gospel as I'm not exactly sure.  But I've never had to
movelast before the recordcount.  The only problem is each back-end database
handles recordcount differently (and some don't support it at all).  From what
I've seen, you typically must implement the recordset as a client-side cursor
to collect an accurate recordcount.  This isn't neccessarily a bad thing (and
can even be good in some cases) but sometimes it's inconvenient.

-Curtis Spendlove
-Solstice Software

 
 
 

DAO Recordcount vs. ADO Recordcount

Post by Keith Kelle » Fri, 10 Dec 1999 04:00:00


The best thing to do (safely) is open a recordset that does a "Count(*)"
function and assign the return value to a variable.  It works correctly
everytime!

DAO Example:

dim rs as recordset, mydb as database
dim RecordCount as Long

set mydb=opendatabase(..........)
set rs = mydb.OpenRecordSet("Select Count(*) AS NumRecs From <<tablename>>",
dbOpenSnapshot)
RecordCount = rs!NumRecs
IF RecordCount > 0 Then
    dosomething...
End If

rs.close
mydb.close
Set mydb = nothing

Just perform a similar action in ADO.  I don't fool with ADO much!  By the
way, this procedure is much, much faster than the .Recordcount property in
that the database engine performs the necessary query and simply returns a
value.  This is very noticeable when connecting to an SQL database.

Quote:>In DAO, to get a correct Recordcount, you had to do a movelast and a
>movefirst of the recordset before you could use the recordcount.

>Is this also necessary in ADO?

>Many thanks and greetings from Brugge (Bruges - Belgium),

>Michel

 
 
 

DAO Recordcount vs. ADO Recordcount

Post by Andrew Count » Sat, 11 Dec 1999 04:00:00


In DAO you needed to movelast before getting a Recordcount because the DAO
object got the count from the number of Records processed by the Jet engine.
Doing a movelast caused all the records to be passed through the Jet engine.
In ADO, the recordcount is a property of the ADO object, not a function
counting the Jet process, so the movelast should not have any affect on your
count.

Hope this Helps.
Andrew Counts


Quote:> >In DAO, to get a correct Recordcount, you had to do a movelast and a
> >movefirst of the recordset before you could use the recordcount.

> >Is this also necessary in ADO?

> Don't take this as gospel as I'm not exactly sure.  But I've never had to
> movelast before the recordcount.  The only problem is each back-end
database
> handles recordcount differently (and some don't support it at all).  From
what
> I've seen, you typically must implement the recordset as a client-side
cursor
> to collect an accurate recordcount.  This isn't neccessarily a bad thing
(and
> can even be good in some cases) but sometimes it's inconvenient.

> -Curtis Spendlove
> -Solstice Software

 
 
 

1. SQL Count vs. ADO RecordCount

Hi. I need to get the number of rows returned by a query and I'd like to
avoid counting the rows once returned in an ADO recordset. I've read
somewhere that one can use T-SQL's Count aggregate function in such a way so
as to perform the query of choice AND get the row count at the same time.
But, I'm having trouble figuring out how to do that with the query that I
have...

SELECT N.entID, N.entName, N.entNameAbbrev
FROM tblNodes N LEFT JOIN tblEdges E
ON N.entID = E.IDEntity2
WHERE N.entName = 'AT&T'

I halfway expect that I can't use Count with this query.

Any suggestions?

Brian

2. using merge replication instead of transactional repl

3. DAO Recordcount property in multiuser environment

4. "Setup says can't connect to server"

5. DAO and RecordCount ????

6. How tp position DB files on two physical HD

7. redim vs rs.RecordCount

8. How to load an image to an image field of a SQL Table

9. .RecordCount vs Count(*)

10. ADO and rs.recordCount (Off-Topic?)

11. ADO RecordCount = 0...not right.

12. ADO and rs.RecordCount (Off Topic?)

13. ADO - no RecordCount returned