Checking for Empty Dataset -- Simple Question

  • Thread starter Thread starter Ron
  • Start date Start date
R

Ron

Can anyone tell me how to check and see if a dataset is empty?

I am writing a search function that returns a dataset and binds it to a
datagrid. If no data is found, I would like to make the grid invisible and
have a label appear stating that no data was found.

Any suggestions?

Thanks,

Ron Rodenberg
 
Thanks a lot Gaston, I appreciate your help.


GastonQ said:
Hi Ron, to check an empty DataSet you must verify the Rows
of the DataTable object that contains the database query
result.

For example:
DataSet ds = new DataSet( "MyTable" );
...
if( ds.Tables[ "MyTable" ].Rows.Count == 0 )
// No records
else
// Do something...

Regards
Gaston Quirque
Microsoft MVP
-----Original Message-----
Can anyone tell me how to check and see if a dataset is empty?

I am writing a search function that returns a dataset and binds it to a
datagrid. If no data is found, I would like to make the grid invisible and
have a label appear stating that no data was found.

Any suggestions?

Thanks,

Ron Rodenberg


.
 
Back
Top