Getting a Record Count

  • Thread starter Thread starter Jeremy Ames
  • Start date Start date
J

Jeremy Ames

I am trying to find out how many rows are returned from a select statement
that I am putting into a data reader object. What is the easiest way to do
this?
 
You'll have to iterate through the reader. The closest you can get wihtout
doing this is DataReader.HasRows() which returns true or false and only
works wiht the 1.1 framework.

otherwise...

int i = 0;

while(rdr.Read()){

///do whatever;
i++;
}
 
Back
Top