I'm populating a DataTable using a DataAdapter.Fill() statement. It works
just fine as long as the return is successful. However, when my query
returns no rows, rather than getting a "0" for rows returned (the function
is supposed to return an integer), I get a "System.ArgumentNullException"
apparently because there is nothing to populate the DataTable with.

How can I trap for this without resorting to exception handling?

TIA

Michael

Re: Null returns from DataAdapter.Fill() by W

W
Wed Jan 05 14:00:18 CST 2005

How are you checking it? You can use Rows.Count ie
return (DataSetName != null) ? DataSetName.TableName.Rows.Count : 0;

--
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Michael Kellogg" <mkellogg@WEDELIVERcc3.com> wrote in message
news:Xns95D5782FB90D2mkelloggWEDELIVERcc3@207.46.248.16...
> I'm populating a DataTable using a DataAdapter.Fill() statement. It works
> just fine as long as the return is successful. However, when my query
> returns no rows, rather than getting a "0" for rows returned (the function
> is supposed to return an integer), I get a "System.ArgumentNullException"
> apparently because there is nothing to populate the DataTable with.
>
> How can I trap for this without resorting to exception handling?
>
> TIA
>
> Michael



Re: Null returns from DataAdapter.Fill() by Miha

Miha
Wed Jan 05 15:24:07 CST 2005

Hi Michael,

It shouldn't crash like that.
What provider are you using?
Can you show us the piece of code that causes this behaviour?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

"Michael Kellogg" <mkellogg@WEDELIVERcc3.com> wrote in message
news:Xns95D5782FB90D2mkelloggWEDELIVERcc3@207.46.248.16...
> I'm populating a DataTable using a DataAdapter.Fill() statement. It works
> just fine as long as the return is successful. However, when my query
> returns no rows, rather than getting a "0" for rows returned (the function
> is supposed to return an integer), I get a "System.ArgumentNullException"
> apparently because there is nothing to populate the DataTable with.
>
> How can I trap for this without resorting to exception handling?
>
> TIA
>
> Michael



Re: Null returns from DataAdapter.Fill() by Sahil

Sahil
Wed Jan 05 16:19:35 CST 2005

Usually you get that error/exception if you pass in a null/nothing dataset
to dataadapter.fill.
Other than that, did you see this KB article -
http://support.microsoft.com/kb/313028/EN-US/ <-- maybe that'll help.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik



"Michael Kellogg" <mkellogg@WEDELIVERcc3.com> wrote in message
news:Xns95D5782FB90D2mkelloggWEDELIVERcc3@207.46.248.16...
> I'm populating a DataTable using a DataAdapter.Fill() statement. It works
> just fine as long as the return is successful. However, when my query
> returns no rows, rather than getting a "0" for rows returned (the function
> is supposed to return an integer), I get a "System.ArgumentNullException"
> apparently because there is nothing to populate the DataTable with.
>
> How can I trap for this without resorting to exception handling?
>
> TIA
>
> Michael



RE: Null returns from DataAdapter.Fill() by Luis

Luis
Thu May 19 17:25:31 CDT 2005

Hi Michael
I have the same problem on having populated the DATASET.
Sending departs from the code in order that they could help us.


sqldaCliente.Fill(dsReporte, "CUS")
sqldaRegVent.Fill(dsReporte, "IMS_RegVtas")

They are related tables and on having populated with the DATAADAPTER.FILL

return message error: VALUE CANNOT BE NULL

Thank you for hishelp

Luis.


"Michael Kellogg" wrote:

> I'm populating a DataTable using a DataAdapter.Fill() statement. It works
> just fine as long as the return is successful. However, when my query
> returns no rows, rather than getting a "0" for rows returned (the function
> is supposed to return an integer), I get a "System.ArgumentNullException"
> apparently because there is nothing to populate the DataTable with.
>
> How can I trap for this without resorting to exception handling?
>
> TIA
>
> Michael
>