About DataAdapter.Update

  • Thread starter Thread starter bhuff
  • Start date Start date
B

bhuff

The dataadapter compares the current dataset with the
original dataset in determining the series of
INSERT,DELETE and UPDATE to make the datasource reflect
the current dataset. What about the case when tables in
a dataset is cleared and then rebuilt. Does the
dataadapter send a DELETE removing the corresponding
datasource or it is "smarter" and affects only changes
between "before" and "after" of the dataset.

Brad
 
Hi Brad,

The DataSet does not compare the current with the previous, it keeps track
over all the changes performed.
Each DataRow in a DataTable has a RowState property that tells if the row
has been Added, Deleted etc.
This state is used to determine what the DataAdapter should do with the row.
If you delete all the DataRows, they will all be marked as deleted. If you
then rebuild the table, the rows are marked as added. When the DataAdapter
updates the datasource, all the previous rows will be deleted, and the new
ones added.
Note that when using the Fill method of the DataAdapter, the RowState is not
set to Added, it indicates Unchanged.
The RowState can be changed by using the AcceptChanges and RejectChanges
methods.

Hopes this helps.

Chris
 
Thanks

-----Original Message-----
Hi Brad,

The DataSet does not compare the current with the previous, it keeps track
over all the changes performed.
Each DataRow in a DataTable has a RowState property that tells if the row
has been Added, Deleted etc.
This state is used to determine what the DataAdapter should do with the row.
If you delete all the DataRows, they will all be marked as deleted. If you
then rebuild the table, the rows are marked as added. When the DataAdapter
updates the datasource, all the previous rows will be deleted, and the new
ones added.
Note that when using the Fill method of the DataAdapter, the RowState is not
set to Added, it indicates Unchanged.
The RowState can be changed by using the AcceptChanges and RejectChanges
methods.

Hopes this helps.

Chris





.
 
Back
Top