Home

AcceptChangesDuringFill

AcceptChanges is a method in ADO.NET used to commit the current in-memory changes in a DataTable or DataSet. When called, it marks all rows as unchanged and updates their internal versions, effectively resetting the change tracking state since the last time AcceptChanges was invoked. Deleted rows are removed from the collection, while added and modified rows have their original values aligned with the current values. Any row-level errors are cleared.

In practice, AcceptChanges serves as a way to signal that the in-memory view of data represents a

Cautions and limitations are important. Calling AcceptChanges manually before pushing updates to a data source effectively

stable,
synchronized
state.
It
is
commonly
invoked
after
a
successful
update
operation
to
the
data
source,
such
as
after
a
DataAdapter.Update
call.
In
this
normal
flow,
the
data
adapter
uses
the
row
states
to
determine
which
commands
to
execute
(insert,
update,
delete),
and
the
subsequent
AcceptChanges
call
commits
those
changes
to
the
in-memory
representation.
Since
DataAdapter.Update
typically
calls
AcceptChanges
automatically,
developers
rarely
need
to
call
it
manually,
except
in
special
scenarios
where
the
update
lifecycle
is
managed
in
a
custom
way.
discards
pending
changes
from
the
in-memory
view,
and
the
update
process
may
not
reflect
intended
edits.
AcceptChanges
does
not
affect
data
in
the
underlying
data
source;
it
only
alters
the
in-memory
RowState
and
version
information.
For
restoring
original
values
from
before
changes,
RejectChanges
can
be
used
instead.