DbDataAdapter.Fill Method (what if table returns empty)

  • Thread starter Thread starter mB
  • Start date Start date
M

mB

Suppose I use the fill method to add rows to a dataset, but that my table
doesn't contain data.

What does the fill method do when there are no records in the table?

And what's the best way to test for no records in the dataset before doing
any functions on the dataaset?

For example,
drows = dsTmp.Tables(0).Select("PartNo = '" & txtPart.Text + "'")

Gives an exception, cannot find table 0.

So, with this example, before trying to load a data row, how can I find out
if there is even any data in the data set to prevent this error?

Or is it a good idea to load the dataset with an empty dummy record - if
even possible?

Thanks, -m

..
 
First read the dsTmp.Tables.Count property to determine if the DataSet
contains any tables, then you can load the tables by index e.g.
dsTmp.Tables(0) and then check their Rows.Count property to see how many
rows are contained

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups
 
Back
Top