Null returns from DataAdapter.Fill()

  • Thread starter Thread starter Michael Kellogg
  • Start date Start date
M

Michael Kellogg

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
 
How are you checking it? You can use Rows.Count ie
return (DataSetName != null) ? DataSetName.TableName.Rows.Count : 0;
 
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?
 
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.
 
Back
Top