SqlDataReader

  • Thread starter Thread starter lakshmi
  • Start date Start date
L

lakshmi

When SqlDataReader reads records returned by a query, is
there any way to check if the query returned any rows or
not? Thanks for your help.
 
If you are using 2003, the DataReader has a boolean .HasRows property.

Otherwise you'lll need to iterate through it, at least for one record to
make that determination.
 
Hi Lakshmi,

You can check for the reader records as below and then
iterate through through the reader.

if (reader.Read())
{
// loop through the reader, and do necessary
actions.
}
else
{
// do necessary actions.
}

regards,
Sasikumar
 
Back
Top