MCS MCS - 1 year ago 105
C# Question

How to test if a DataSet is empty?

I'm modifying someone else's code where a query is performed using the following:

DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(sqlString, sqlConn);

How can I tell if the DataSet is empty (i.e. no results were returned)?

Answer Source

If I understand correctly, this should work for you

if (ds.Tables[0].Rows.Count == 0)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download