IDataReader - Any way to get the total rows?

Viewed 9697

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

5 Answers

Maybe not an good idea, but i got count using variable inside while loop. This code work fine for me:

IDataReader reader = SqlHelper.ExecuteReader(sqlConnectionString, Procedure.GetSuperUserOwnerDetails, ProfileName);
int count = 0;
while (reader.Read())
{
   count = count + 1;
}
lblProfileOperator.Text = " Owner : " + count;
Related