I'm not sure that I entirely understand the purpose of the
AcceptChanges methon in a DataView. I added a new record to a DataView
and noticed that its RowState indicated it as being "Added". If I
execute the Update method on an adapter for the table that the DataView
is based on, the new record will indeed be written to the database. But
if I call AcceptChanges prior to executing the Update method, the
RowState for the new record is changed to "Unchanged" and the new
record is not stored in the database when the Update method is
executed.
I don't get it. The .NET documentation clearly states the following:
"Calling AcceptChanges on the DataSet, DataTable, or DataRow will cause
all Original values for a DataRow to be overwritten with the Current
values for the DataRow"
and...
"After verifying the accuracy of changes made to data in a DataTable,
you can accept the changes using the AcceptChanges method of the
DataRow, DataTable, or DataSet, which will set the Current row values
to be the Original values and will set the RowState property to
Unchanged"
This is exactly what it is doing but what's the logic for not allowing
this newly added record to be stored in the database. Just because the
RowState now indicates "Unchanged", this should mean that the new
record should not be stored?? What then is the point of AcceptChanges
if you can't store the changes you've accepted?
Thanks for your response.
Johann Blake