G
Guest
If you pull changes from a dataset and send the changes to update method of a
data adapter, when you merge the changes back to the original dataset you may
end up adding duplicate rows. This happens when the PK is updated either
because a row is being added and the PK is an Identity column or the row was
is being updated and the PK was also updated.
Datasets will merge rows whose original version of key(s) match and add rows
being merged if the original versions of the key(s) do not match any row in
the original dataset.
I noticed that the when you call the update method on the dataset containing
the changes, the original version of the columns are updated to the current
version. This causes the problem because, now, the original versions of the
PK of the original dataset and changes dataset do not match.
Since this is the case what is the purpose of calling the AcceptChanges
method after calling the data adapter's Update method??
So anytime the PK is updated, this will cause the updated row to be added to
the dataset rather than being merged. So you have to jump through some
programming hoops, to either remove potential duplicate rows in the original
dataset, or reset the original version of the PK in the dataset with the
changes.
Isn't there a simpler way to handle this?
data adapter, when you merge the changes back to the original dataset you may
end up adding duplicate rows. This happens when the PK is updated either
because a row is being added and the PK is an Identity column or the row was
is being updated and the PK was also updated.
Datasets will merge rows whose original version of key(s) match and add rows
being merged if the original versions of the key(s) do not match any row in
the original dataset.
I noticed that the when you call the update method on the dataset containing
the changes, the original version of the columns are updated to the current
version. This causes the problem because, now, the original versions of the
PK of the original dataset and changes dataset do not match.
Since this is the case what is the purpose of calling the AcceptChanges
method after calling the data adapter's Update method??
So anytime the PK is updated, this will cause the updated row to be added to
the dataset rather than being merged. So you have to jump through some
programming hoops, to either remove potential duplicate rows in the original
dataset, or reset the original version of the PK in the dataset with the
changes.
Isn't there a simpler way to handle this?