Groups | Blog | Home
all groups > dotnet general > june 2005 >

dotnet general : How to sync-up DataSet during multi-table update


PV
6/28/2005 12:55:56 PM
When performing a parent-child table updates using DataAdapters, the
updates have to be performed in at least two passes. The deletes must
be done child first, then parent. Conversely, the inserts must be done
parent first, then child. This is generally accomplished by using
DataSet.GetChanges(DataRowState.Deleted) and
DataSet.GetChanges(DataRowState.Inserted) respectively.

My question is: What is the best way after this to sync up the
original DataSet with what was actually done by the database stored
procedure? For example, if a primary key was generated for the
inserted data?

When you update the source DataSet directly, the DataAdapter (at least
SqlDataAdapter) automatically updates the temporary primary keys with
the new primary keys.

I have tried to use DataSet.Merge, but that does not update the
original rows - it just appends the inserts so that now I have twice as
many new rows.

What is the best practice?
PV
7/11/2005 12:57:50 PM
No responses yet? Where are all the MS gurus? Certainly this must be
a common problem.
AddThis Social Bookmark Button