Here is the result of using the technique of the article. It works, but I
cannot explain how. Looking at the Original Dataset and the Changes Datatset
their original values do not match nor do their current values. The only
explanation I can come up with is the dataset tries more than one matching
scheme. If match on orginal values fails, try current values. If match on
current values fails, try matching original value to current value. If match
found, merge rows else add row.
-----------------------
BEFORE MERGE - Original DataSet
dsOption
---------------------------
tblGroup
Original: Added
Current: -2 -- Tone -- Added
---------------------------
tblOptionGroup
Original: Added
Current: -2 -- BW -- Black & White -- Added
Original: Added
Current: -2 -- CZ -- Colorize -- Added
Original: Added
Current: -2 -- SEP -- Sepia -- Added
BEFORE MERGE - dsChanges
dsChanges
---------------------------
tblGroup
Original: -2 -- Tone -- Modified
Current: 20 -- Tone -- Modified
---------------------------
tblOptionGroup
Original: -2 -- BW -- Black & White -- Modified
Current: 20 -- BW -- Black & White -- Modified
Original: -2 -- CZ -- Colorize -- Modified
Current: 20 -- CZ -- Colorize -- Modified
Original: -2 -- SEP -- Sepia -- Modified
Current: 20 -- SEP -- Sepia -- Modified
AFTER MERGE - Before Accept Changes - Original Dataset
dsOption
---------------------------
tblGroup
Original: -2 -- Tone -- Modified
Current: 20 -- Tone -- Modified
---------------------------
tblOptionGroup
Original: -2 -- BW -- Black & White -- Modified
Current: 20 -- BW -- Black & White -- Modified
Original: -2 -- CZ -- Colorize -- Modified
Current: 20 -- CZ -- Colorize -- Modified
Original: -2 -- SEP -- Sepia -- Modified
Current: 20 -- SEP -- Sepia -- Modified
AFTER MERGE - After Accept Changes - Original Dataset
dsOption
---------------------------
tblGroup
Original: 20 -- Tone -- Unchanged
Current: 20 -- Tone -- Unchanged
---------------------------
tblOptionGroup
Original: 20 -- BW -- Black & White -- Unchanged
Current: 20 -- BW -- Black & White -- Unchanged
Original: 20 -- CZ -- Colorize -- Unchanged
Current: 20 -- CZ -- Colorize -- Unchanged
Original: 20 -- SEP -- Sepia -- Unchanged
Current: 20 -- SEP -- Sepia -- Unchanged
"WhiskyRomeo" wrote:
Since I can't get answer from the author, can someone address this?
In this article . . .
http://msdn.microsoft.com/msdnmag/is...s/default.aspx
In the "The Transaction and Sequence" paragraph, the author makes this
statement:
"The row is left with different original and current values so that when I
merge the delta DataSet with the originating DataSet, they will sync with
each other properly, using the original values of the OrderID DataColumns. "
Since the author is talking about the insertion of "new" orders where the
Order_ID column is an identity column along with the associated detail
records, the orginal dataset has only current values -- there are no original
values. Added records are merged on the basis of current values.
Here is the code:
DataSet oDsDelta = oOrder.SaveData(oDs.GetChanges());
oOrder = null;
oDs.EnforceConstraints = false;
oDs.Merge(oDsDelta.Tables["Orders"]);
oDs.Merge(oDsDelta.Tables["OrderDetails"]);
oDs.AcceptChanges();
oDs.EnforceConstraints = true;
What is too long to post here is the code that takes oDsDelta and ensures
that its rows have an Original Order_ID value equal to the psuedo key value
assigned by the original dataset and a Current Order_ID value equal to the
database's value. So you can assume the that oDsDeleta has an Original value
and Current value. So a given row in oDs might have -1 as the Current value
but no Original value. The corresponding row in the oDsDelta with have
498576 as the Current Value and -1 as the Original value.
Based on this there is no way to merge these rows. Plus, I believe the rows
have differ row states at this point. What am I missing???
This article has the potential to be very helpful if it only works or if I
can understand it correctly.