How to find out whether SqlCe query Has rows?

Posted by Tomas on Stack Overflow See other posts from Stack Overflow or by Tomas
Published on 2010-03-20T13:13:43Z Indexed on 2010/03/20 13:21 UTC
Read the original article Hit count: 287

Filed under:
|

Hi, In my simple db I use SqlCe and I cannot figure out how to correctly find out whether the query has rows or not. HasRows does not work. So far I have this:

_DbCommand.CommandText="SELECT * FROM X"
SqlCeDataReader reader=_DbCommand.ExecuteQuery();

if (reader.FieldCount!=0) //I thought it could work (O rows - 0 fields?), but its true even with 0 rows
{
while (reader.Read())
{
 //
}
}

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about sqlce