HOw to check whether there are null rows in datareader  
Author Message
heartly4u





PostPosted: .NET Framework Data Access and Storage, HOw to check whether there are null rows in datareader Top

Hi


How to check whether there are null rows in a datareader.

here is the query which returns null value.

"select max(attendence) from tblattendance where loginid=34 and att_month='"+december+"'";

but when i check is datareader.hasRows it shows true

when there are no such rows corresponding to month 'december'.

please help me regarding this query.


Thanking you




.NET Development3  
 
 
Jeff Wharton





PostPosted: .NET Framework Data Access and Storage, HOw to check whether there are null rows in datareader Top

Issuing select max(attendence) from tblattendance where loginid=34 and att_month='"+december+"'; will return 1 row with a value of NULL for max(attendence) if no records meet your criteria.

Therefore, all you need to do is check if the returned column contains NULL and you'll know that no rows exist.

Cheers
Jeff



 
 
Dah_cn





PostPosted: .NET Framework Data Access and Storage, HOw to check whether there are null rows in datareader Top

Maybe you can use DataReader[int index] to query the value.

For your sample, use datareader[0].