Hi,

Can anybody tell me when you would use DataSet.AcceptChanges. If you use it,
then all the new records are reset to be seen as original records
(unchanged), and hence cannot be updated into the datasource. Therefore I've
been using the update method which does both Accet changes (rebuilds the row
numbers in the data table) & saves to datasource.
I can understand RejectChanges as this would discard new rows before the
update, but why AcceptChanges? When would you use it?

Thanks for any ideas on this
Ant

Re: c# - AcceptChanges - What's it used for? by Val

Val
Mon Mar 06 20:59:58 CST 2006

Hi,

Sometimes you could use DataSet as a disconnected source that never works
with the database. Some sort of the local datasource. In this case you could
use AcceptChanges to simulate updated data and continue with the next batch
of the data. I am pretty sure some developers will find some other use of
this functionality

--
Val Mazur
Microsoft MVP
http://xport.mvps.org


"Ant" <Ant@discussions.microsoft.com> wrote in message
news:0F373379-602E-491B-B553-69247D0B8BD8@microsoft.com...
> Hi,
>
> Can anybody tell me when you would use DataSet.AcceptChanges. If you use
> it,
> then all the new records are reset to be seen as original records
> (unchanged), and hence cannot be updated into the datasource. Therefore
> I've
> been using the update method which does both Accet changes (rebuilds the
> row
> numbers in the data table) & saves to datasource.
> I can understand RejectChanges as this would discard new rows before the
> update, but why AcceptChanges? When would you use it?
>
> Thanks for any ideas on this
> Ant



Re: c# - AcceptChanges - What's it used for? by Cor

Cor
Tue Mar 07 00:46:00 CST 2006

Ant,

In addition to Val.

Have a look at this not seldom used code
if (Ds.HasChanges) {da.Update(ds.GetChanges)};
ds.AcceptChanges();

The dataadapter sets all rows that are updated to unchanged (or removes
them), however in this case is the GetChanges a copy of that dataset.
With the ds.AcceptChanges are all rows in the dataset accepted as changed or
removes rows from which is the status deleted.

I hope this gives an idea.

Cor


"Ant" <Ant@discussions.microsoft.com> schreef in bericht
news:0F373379-602E-491B-B553-69247D0B8BD8@microsoft.com...
> Hi,
>
> Can anybody tell me when you would use DataSet.AcceptChanges. If you use
> it,
> then all the new records are reset to be seen as original records
> (unchanged), and hence cannot be updated into the datasource. Therefore
> I've
> been using the update method which does both Accet changes (rebuilds the
> row
> numbers in the data table) & saves to datasource.
> I can understand RejectChanges as this would discard new rows before the
> update, but why AcceptChanges? When would you use it?
>
> Thanks for any ideas on this
> Ant



Re: c# - AcceptChanges - What's it used for? by Truong

Truong
Tue Mar 07 02:51:42 CST 2006

> if (Ds.HasChanges) {da.Update(ds.GetChanges)};
>ds.AcceptChanges();
As a note, it is often neccesary to call Merge after Update(GetChanges)
so that auto-generated and values changes by other users filled back to
the dataset (if the insert/update/delete command has output params or
return result set).

Thi


Re: c# - AcceptChanges - What's it used for? by Christian

Christian
Tue Mar 07 11:58:37 CST 2006

"Truong Hong Thi" <thi1981@gmail.com> schrieb im Newsbeitrag
news:1141721502.357158.52000@z34g2000cwc.googlegroups.com...
>> if (Ds.HasChanges) {da.Update(ds.GetChanges)};
>>ds.AcceptChanges();
> As a note, it is often neccesary to call Merge after Update(GetChanges)
> so that auto-generated and values changes by other users filled back to
> the dataset (if the insert/update/delete command has output params or
> return result set).
>
> Thi
>

yepp, just had that case. But I did not want that complicated way of
updating the duplicated rows in GetChanges() and then merge them into the
original dataset again, so i ended up doing something like

dataset.update(dataset.datatable.select(nothing,nothing,DataRowState.Added
Or DataRowState.Modified Or DataRowState.Deleted))

thereby updating the original rows. Does anyone know a good reason for NOT
doing it that way?