Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Recordcount

Author  Topic 

p2bl
Yak Posting Veteran

54 Posts

Posted - 2001-11-30 : 07:49:01
Hi.
I found that when I use a recordset to receive the result of a
stored procedure executed by a connection object,the recordset's recordcount always -1 while the EOF=false.I have tried to set the cursor type and the lock type of the recordset object.Problerm still.
So how could I do.Thanks

I do not know what is what

izaltsman
A custom title

1139 Posts

Posted - 2001-11-30 : 08:49:21
This is because ADO is fetching data into your cursor asynchronously (so it does not know how many records there is going to be until it reads all the data in). I believe (and I'm not 100% sure) that if you use a client-side cursor (set cursorlocation to adUseClient), the recordcount will be correct. This could impact perceived performance however when you are reading large amounts of data into your cursor.



Edited by - izaltsman on 11/30/2001 08:52:52
Go to Top of Page

p2bl
Yak Posting Veteran

54 Posts

Posted - 2001-11-30 : 09:20:19
Thanks
But what confused me is that if the recordset object receive result
from a sql,It does have a recordcount with a static lock type
like this:
oCn:a conection object
oRst a recordset object

oRst.open "select * from table1",oCn,1,1 'This has a correct recordcount
oRst.open "up_mystoreprocedure",Ocn,1,1 'this recorcount=-1


Go to Top of Page

izaltsman
A custom title

1139 Posts

Posted - 2001-11-30 : 09:37:54
That's the way it is supposed to be... Here is a quote from MSDN Library:

quote:

The cursor type of the Recordset object affects whether the number of records can be determined. The RecordCount property will return -1 for a forward-only cursor; the actual count for a static or keyset cursor; and either -1 or the actual count for a dynamic cursor, depending on the data source.



Go to Top of Page
   

- Advertisement -