PC Review


Reply
Thread Tools Rate Thread

DbDataAdapter.Fill Method (what if table returns empty)

 
 
mB
Guest
Posts: n/a
 
      18th Sep 2004
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

..


 
Reply With Quote
 
 
 
 
Peter Foot [MVP]
Guest
Posts: n/a
 
      18th Sep 2004
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/...ity/newsgroups

"mB" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
> .
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Table Adapter method returns no rows, but it should! Cor Ligthert[MVP] Microsoft C# .NET 0 1st Aug 2008 01:21 PM
DbDataAdapter.Fill() - just the first row =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= Microsoft ADO .NET 9 26th Apr 2007 11:14 PM
ThreadAbortException from DbDataAdapter.Fill Hans Reins Microsoft ADO .NET 1 2nd Jun 2005 02:19 PM
Re: Memory leak(strings) in DbDataAdapter.Fill Val Mazur \(MVP\) Microsoft ADO .NET 0 6th May 2005 01:59 AM
I don't want DbDataAdapter.Fill to call SqlDataReader.NextResult James K. Microsoft ADO .NET 2 28th Nov 2003 10:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:03 AM.