Home All Groups Group Topic Archive Search About

Updating a dataadapter

Author
21 Jun 2006 12:43 AM
mfleet1973@yahoo.ca
Hi Gang.

I'm using VB.Net 2003.  In the following code I'm updating the
dataadapter with a new record added to the table:

OleDbDataAdapter1.Update(DataSet11.GetChanges, "Table")

However, when I add another record and update the dataadapter again,
the first record gets added a second time.  Is there something else
that needs to be done after doing the update?

Thanks a lot!!

Mike.

Author
21 Jun 2006 2:40 AM
Steven Nagy
Rather than calling DataSet11.GetChanges, just call the Dataset.
Ie:

OleDbDataAdapter1.Update(DataSet11, "Table")

Alternatively you can keep your existing code and call:
DataSet11.AcceptChanges()
after the line of code specified below.



mfleet1***@yahoo.ca wrote:
Show quoteHide quote
> Hi Gang.
>
> I'm using VB.Net 2003.  In the following code I'm updating the
> dataadapter with a new record added to the table:
>
> OleDbDataAdapter1.Update(DataSet11.GetChanges, "Table")
>
> However, when I add another record and update the dataadapter again,
> the first record gets added a second time.  Is there something else
> that needs to be done after doing the update?
>
> Thanks a lot!!
>
> Mike.
Author
21 Jun 2006 5:20 AM
Cor Ligthert [MVP]
MFleet,

In addition to Steven, this behaviour is because the getchanges creates a
copy dataset.

Cor

<mfleet1***@yahoo.ca> schreef in bericht
Show quoteHide quote
news:1150850626.501497.99630@p79g2000cwp.googlegroups.com...
> Hi Gang.
>
> I'm using VB.Net 2003.  In the following code I'm updating the
> dataadapter with a new record added to the table:
>
> OleDbDataAdapter1.Update(DataSet11.GetChanges, "Table")
>
> However, when I add another record and update the dataadapter again,
> the first record gets added a second time.  Is there something else
> that needs to be done after doing the update?
>
> Thanks a lot!!
>
> Mike.
>