Search code examples
c#countrowsdatareader

IDataReader - Any way to get the total rows?


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();?


Solution

  • No.

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