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

Determine is a dataset is empty

P: n/a
Hi,

I am having trouble determining if my dataset is empty.
I have function that populates a dataset from a database and then retuens
it. If the database contains no data then the dataset will be completely
empty, and then when I go to databind() it to a combo box and error will be
throw.

What I whould like to do is check the dataset from code to see if it is
empty.

can anybody please point me in the direction of how to do this.

many thanks in advance.

cheers

martin
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
a dataset always contains datatable(s)....
if your dataset has only one datatable (ie results of one select query)
all you have to do is something like this

int rowCount = myDataSet.Tables[0].Rows.Count

check the count and see if its zero... ie no records found..

--
Regards,

HD

"martin" <ma***************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

I am having trouble determining if my dataset is empty.
I have function that populates a dataset from a database and then retuens
it. If the database contains no data then the dataset will be completely
empty, and then when I go to databind() it to a combo box and error will be throw.

What I whould like to do is check the dataset from code to see if it is
empty.

can anybody please point me in the direction of how to do this.

many thanks in advance.

cheers

martin

Nov 18 '05 #2

P: n/a
Hi,

Thanks for that. Although I'm not sure if the syntax

int rowCount = myDataSet.Tables[0].Rows.Count

is correct. The way I found to get the number of rows in the first table of
a dataset was to iterate through then and count them in a

For ... Each loop

would be interested in a way to do this in one line similar to what you had
above.

cheers

martin.

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:OK**************@TK2MSFTNGP11.phx.gbl...
a dataset always contains datatable(s)....
if your dataset has only one datatable (ie results of one select query)
all you have to do is something like this

int rowCount = myDataSet.Tables[0].Rows.Count

check the count and see if its zero... ie no records found..

--
Regards,

HD

"martin" <ma***************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

I am having trouble determining if my dataset is empty.
I have function that populates a dataset from a database and then retuens it. If the database contains no data then the dataset will be completely
empty, and then when I go to databind() it to a combo box and error will

be
throw.

What I whould like to do is check the dataset from code to see if it is
empty.

can anybody please point me in the direction of how to do this.

many thanks in advance.

cheers

martin


Nov 18 '05 #3

P: n/a
if you are using dataset then u should be able to use the count property to
check the total count

--

Regards,

HD
"martin" <ma***************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

Thanks for that. Although I'm not sure if the syntax

int rowCount = myDataSet.Tables[0].Rows.Count

is correct. The way I found to get the number of rows in the first table of a dataset was to iterate through then and count them in a

For ... Each loop

would be interested in a way to do this in one line similar to what you had above.

cheers

martin.

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:OK**************@TK2MSFTNGP11.phx.gbl...
a dataset always contains datatable(s)....
if your dataset has only one datatable (ie results of one select query)
all you have to do is something like this

int rowCount = myDataSet.Tables[0].Rows.Count

check the count and see if its zero... ie no records found..

--
Regards,

HD

"martin" <ma***************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

I am having trouble determining if my dataset is empty.
I have function that populates a dataset from a database and then retuens it. If the database contains no data then the dataset will be completely empty, and then when I go to databind() it to a combo box and error will
be
throw.

What I whould like to do is check the dataset from code to see if it

is empty.

can anybody please point me in the direction of how to do this.

many thanks in advance.

cheers

martin



Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.