By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,341 Members | 1,395 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,341 IT Pros & Developers. It's quick & easy.

Checking for Empty Dataset -- Simple Question

P: n/a
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
Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
If MyDataSet.Tables.Count = 0 Then 'it's empty

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net

"Ron" <ro*@razorvision.net> wrote in message
news:be********@library1.airnews.net...
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

Nov 17 '05 #2

P: n/a
Ron
Thanks a lot Gaston, I appreciate your help.
"GastonQ" <ga************@yahoo.com.ar> wrote in message
news:04****************************@phx.gbl...
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
.

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.