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
 
Or :

If reader.HasRows then
Do While reader.Read()
...
Loop
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top