IDataReader - Any way to get the total rows?

michael picture michael · Jul 18, 2011 · Viewed 8.4k times · Source

Is there any way to get the total number of rows returned from a SQL query (from the IDataReader) before iterating through the rows by using reader.Read();?

Answer

SLaks picture SLaks · Jul 18, 2011

No.

IDataReader is a simple forward-only view of a resultset; it cannot get a count.