PDA

Click to See Complete Forum and Search --> : Recordcount property with ADO Keysets


Jimbob
Jun 5th, 2000, 08:46 PM
Do Keyset type cursors in ADO not support .Recordcount, or what??????

if I run a simple query like this:

SELECT * FROM ClientProfile;

as a keyset, i get a recordcount of -1. All the records are in there and I can navigate thru it, eof/bof seem to work but i can't get the count, which is what i need

if i open it as a Forward Only, or a Dynamic, i get a recordcount of 26.

is there a way around this???

Mongo
Jun 5th, 2000, 10:14 PM
When you request the RecordCount for a serverside recordset, a -1 may return. This occurs with ActiveX Data Objects (ADO) version 2.0 when the CursorType is adOpenForwardonly or adOpenDynamic. This occurs with ADO 1.5 only when the cursortype is adOpenForwardonly

You don't say whether or not you're using an MS driver/database. MS drivers are infamous for not working with non-MS databases. Officially, MS blames the non-MS provider for this error.

Also, not all combinations of LockType and CursorType work together. Changing a LockType sometimes forces a change in the CursorType; and this then creates the conditions for the -1 recordcount return. Most frustrating; but the bottom line is: forward only cursors will not return a reliable RecordCount.

You have to either use adOpenKeyset or adOpenStatic as the CursorType for server side cursors or use a client side cursor. Client side cursors use only adOpenStatic for CursorTypes regardless of which CursorType you select.