Checking for Empty Dataset -- Simple Question

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
 
R

Ron

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


.
 

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

Members online

No members online now.

Forum statistics

Threads
474,083
Messages
2,570,591
Members
47,212
Latest member
RobynWiley

Latest Threads

Top