DataSet - GetChanges() and Merge() Questions



I need to collect a "delta" between two Datasets: DS1 and DS2. DS2 was
created from DS1.

We cannot use/rely on RowState because of the operations involved in
generating DS2. Essentially all rows/columns are deleted and most are

Can I use Merge between DS1/DS2 to generate a "Delta" Dataset? Something like:

// Code that extensively modifies the DS2 Dataset
DS1.AcceptChanges(); // Reset RowState info - it is useless
DS2.AcceptChanges(); // Reset RowState info - it is useless
DS1.Merge(DS2, true);
sChanges = DS1.getChanges().GetXML();

I end up geting some XML - but it seems to bear little relation to the
changed area of the DataSet. Perhaps the RowState is killing me... is there a
way to get GetChanges() to work even if RowState is not valid?

It appears Merge() requires a Primary Key in order to detect row changes vs.
additions. Are there other limitations to using Merge?

Sorry for such a generic request. Worst case I will walk thru each table in
the Dataset determining changes/adds/etc... but I hate to do this if it's
already covered in the existing methods.





I over-simplified in order to present as quickly as possible. A bad idea ;-(

Basically our dataset of tables are each 'dis-assembled' with most rows
becoming columns and vise-versa. The UI allows the users to add in new
'columns' or delete existing 'columns' in the UI. These columns actually
correspond to rows in the original Dataset.

But essentially once we have converted thru this row->columns, edits,
columns->rows routines -- all rows in the Dataset are flagged as Added - even
if there were no 'net' changes to them.

So the RowState has to be disregarded: The Dataset we get back will have the
exact same schema as the original (and most of the data) but is a completely
new set of tables.
Why are you making a copy of DS1 and modifying DS2? Why not just modify DS1?

Again - bad communication from trying to be terse...this code snippet should
be more clear.

// Code that extensively modifies the dsLive() Dataset

// Flag initial state as clean

// Merge in the changes from dsLive:
// this should not only give us the ds changes, but
// the apropriate RowState for those changes also.
dsOriginal.Merge(dsLive, true);

// GetChanges() should present us with a 'delta' between the DataSets
sChanges = dsOriginal.getChanges().GetXML();

o dsOriginal contains the DataSet prior to any changes.
o dsLive is the final DataSet after modifications.
o Reset the RowState
o Merge should result in the differences being moved into
dsOriginal and flagged with viable RowStates.
o Use GetChanges() to list off the 'delta'


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question