Record count in Reader
-
pathak78 wrote:
Any one have an idea about counting total records in a reader.
Read all the rows out counting as you go. There is no method for giving you a count ahead of time.
Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos
-
Just had another thought. You can send the query
SELECT COUNT(*) FROM ....
to the datbase followed by the query where you replaceCOUNT(*)
with the columns that you actually want. That way the first result set out of the Data Reader will contain the count. Remember to put both in a transaction so that the count does not change between queries as it is possible another process could sneak in and insert or delete a row in the table you are selecting from.
Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos
-
Just had another thought. You can send the query
SELECT COUNT(*) FROM ....
to the datbase followed by the query where you replaceCOUNT(*)
with the columns that you actually want. That way the first result set out of the Data Reader will contain the count. Remember to put both in a transaction so that the count does not change between queries as it is possible another process could sneak in and insert or delete a row in the table you are selecting from.
Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos