OleDbDataReader record count

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

How can i get the record count for the OleDbDataReader (or the associated
oledbcommand)?

Thanks

Regards
 
You can declare a counter and in a While dr.Read loop,
increment it each time. In vs 2003, there is a HasRows
property, but that only confirms that you have rows,
doesn't give you the count of them.

Off of the top of my head, I can't think of a way to get
it without iteration, either using while dr.Read or
NextResult.


Hope this helps.

Bill
 
Bill is right (most Bills are) ;)

It's like asking you exactly how many eggs you have in the
refrigerator--before opening the door and counting. The SQL engine does not
know how many rows qualify for the rowset until all of the rows have been
fetched. Even in cases where it does know, it does not tell the client
unless you create a server-side cursor. Fill uses the DataReader but does
not return control to you until it's through fetching all of the rows.

hth

--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Back
Top