[AccessD] ado recordcount

Haslett, Andrew andrew.haslett at ilc.gov.au
Sun Oct 19 18:48:53 CDT 2003


Save yourself the trouble (and performance cost of opening a recordset), and
execute a:

SELECT COUNT([FieldName]) against the connection.

especially when your not returning or any data (ie, working with the
recordset).

Cheers,
Andrew

-----Original Message-----
From: John Colby [mailto:jcolby at colbyconsulting.com]
Sent: Monday, 20 October 2003 12:52 AM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] ado recordcount


In fact I was just trying to get a record count for testing purposes.  I was
opening a recordset (I thought) and then passing that recordset to another
class, where a "find" was not working.  No se por que.  I ended up replacing
the table name with a SQL string and it started working.  Problem solved, no
recordcount required for testing.

The odd part is that I was opening a different recordset and doing a search
(find) inside of the class, but when passed to another class many of the
recordset properties started failing.  I'd get errors like "addition of this
record failed due to ..." when all I was doing was a find operation.  I
hadn't even done an addrec.  Weird stuff.  However by using a SQL String
instead of the table name, this problem went away.  Again, weird stuff.  I
must admit I'm not an ADO head though so who knows what I was really doing.

In this application, In my form class I am looking for a record in a table
for the form (thus the .Find) and if none found, create a new record.  I
tried the identical thing for controls, but in order to speed things up I
open the recordset in the form class and pass it off to the control class
being instantiated, where the .Find is failing.  I could open the table
directly (Identical code, stolen to do the control recordset), but had to
use an SQL statement for the control recordset.

With much wasted time figuring that out.

Sigh.

John W. Colby
www.colbyconsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Jim Lawrence
(AccessD)
Sent: Sunday, October 19, 2003 11:06 AM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] ado recordcount


Hi John:

In addition to the information supplied by Dave Sharpe with using a server
side cursor location will cause issues. Use 'rs.CursorLocation =
adUseClient' instead of 'rs.CursorLocation = adUseServer'. Most work can be
done with 'static' cursor types. Use adOpenKeyset type cursors only when
updating or deleting and use a pessimistic lock so as to not over-write a
record being used by another.

My two cents worth
Jim



_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

IMPORTANT - PLEASE READ ******************** 
This email and any files transmitted with it are confidential and may 
contain information protected by law from disclosure. 
If you have received this message in error, please notify the sender 
immediately and delete this email from your system. 
No warranty is given that this email or files, if attached to this 
email, are free from computer viruses or other defects. They 
are provided on the basis the user assumes all responsibility for 
loss, damage or consequence resulting directly or indirectly from 
their use, whether caused by the negligence of the sender or not.


More information about the AccessD mailing list