DataReader Count? 
Author Message
 DataReader Count?

Hi, guys.
I guess DataReader object doesn't have Count property.
I don't wanna have to loop through the DataReader just to
get the record count. Can anyone suggest any tips for this?\

TIA



Fri, 31 Dec 2004 01:35:56 GMT  
 DataReader Count?


Quote:
> Hi, guys.
> I guess DataReader object doesn't have Count property.
> I don't wanna have to loop through the DataReader just to
> get the record count. Can anyone suggest any tips for this?\

DataReaders (OleDbDataReader and SqlDataReader) are forward-only by nature.
They stream records so there is no way to tell what the end is without
reaching the end.

If you must know the count, you can execute a "Select Count(column[s])"
statement.
This is only slightly more efficient than you looping through yourself,
however.

Perhaps you should consider a DataSet if you need to see the big picture
before
processing rows.

-c



Fri, 31 Dec 2004 02:03:11 GMT  
 DataReader Count?
Hi, Chad. Thank you very for your suggestion. I guess I will have to try
either DataSet or SELECT COUNT(*).

Thanks!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Fri, 31 Dec 2004 05:00:58 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. datareader count

2. datareader row count

3. How can i count numbers in an int or count characters in a string in the

4. Differencies in compilation: a[count++]=count;

5. Counting the clock... (counting clock cycles)

6. Fill DataTable from DataReader

7. DataReader Questions

8. Choosing between the DataSet or DataReader?!

9. multiple active datareaders on 1 connection

10. Passing datareader object between layers

11. recursive datareader

12. Binding a Datareader to a datagrid

 

 
Powered by phpBB® Forum Software