Click to See Complete Forum and Search --> : Recordcount Returns -1


rickyojr
February 15th, 2000, 09:22 PM
I am using ADO and wanted to get the number of records in a result set. I use SQL SERVER 7.0. But everytime I issuse the command RecordCount, it always return -1 eventhough there are records in the resultset. Are there any solution for this problem?

Thanks

Lothar Haensler
February 16th, 2000, 01:29 AM
here is the answer from MSDn:
"Use either 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. "

April 5th, 2000, 08:06 AM
Had the same problem. You must set your recordset's CursorLocation - adUseClient (I dont' remember the exact constant but I think that's what it is). One problem - it has to read the entire recordset into memory to know how many records are there so if you recordset is really big you'll run out of memory.

d.paulson
April 5th, 2000, 08:43 AM
had the same problem just a few weeks ago. I had two recordsets open (same name). I had forgotten to close one in another form.

David Paulson