After connecting to a database using DataReader
, how can I count the number of rows
?
Thanks.
Data readers are forward only so they don't have the count when first filled. You can do several things to address this:
Here's an example of #1:
Without NextResult: http://www.devx.com/vb2themax/Tip/18807
With NextResult (Doesn't return record count but gives you idea of how to use NextResult): http://bytes.com/topic/asp-net/answers/295793-datareader-nextresults-question
Here's an example of #2: http://support.microsoft.com/kb/308050