J
joproulx
Hello all,
Here is my problem:
I am trying to merge 2 datasets but I don't want to overwrite rows
that are already modified in my working dataset.
Example:
I have one Dataset with only one DataTable in it. The DataTable has
these 2 columns:
Column #1: Name="Id" Type=Int32 (Primary Key)
Column #2: Name="Value" Type=String
My first DataSet (datasetOriginal) has these values in its DataTable:
| Id | Value | RowState |
1 "test1" Unchanged
2 "test2" Modified
My second Dataset (datasetNew) has these values in its DataTable:
| Id | Value | RowState |
1 "newValue" Modified
Then, I merge the datasetNew into the datasetOriginal with this call:
"datasetOriginal.Merge( datasetNew, true );". I set
preserveChanges=true to avoid overwriting the modifications in the
datasetOriginal.
I was thinking that by doing so, it would give me a "datasetOriginal"
with these values in its DataTable:
| Id | Value | RowState |
1 "newValue" Modified
2 "test2" Modified
But what I have is this:
| Id | Value | RowState |
1 "test1" Modified
2 "test2" Modified
The Value is never modified. If I set the "preserveChanges=false" in
the Merge function, then the value is correctly merged.
I have experimented by adding or removing the call to AcceptChanges()
before merging my DataSets, but it doesn't help.
Is there something special I need to do to make the Merge() work or is
there something I don't understand correctly with the behaviour of the
Merge() function?
Thanks in advance,
Jonathan
Here is my problem:
I am trying to merge 2 datasets but I don't want to overwrite rows
that are already modified in my working dataset.
Example:
I have one Dataset with only one DataTable in it. The DataTable has
these 2 columns:
Column #1: Name="Id" Type=Int32 (Primary Key)
Column #2: Name="Value" Type=String
My first DataSet (datasetOriginal) has these values in its DataTable:
| Id | Value | RowState |
1 "test1" Unchanged
2 "test2" Modified
My second Dataset (datasetNew) has these values in its DataTable:
| Id | Value | RowState |
1 "newValue" Modified
Then, I merge the datasetNew into the datasetOriginal with this call:
"datasetOriginal.Merge( datasetNew, true );". I set
preserveChanges=true to avoid overwriting the modifications in the
datasetOriginal.
I was thinking that by doing so, it would give me a "datasetOriginal"
with these values in its DataTable:
| Id | Value | RowState |
1 "newValue" Modified
2 "test2" Modified
But what I have is this:
| Id | Value | RowState |
1 "test1" Modified
2 "test2" Modified
The Value is never modified. If I set the "preserveChanges=false" in
the Merge function, then the value is correctly merged.
I have experimented by adding or removing the call to AcceptChanges()
before merging my DataSets, but it doesn't help.
Is there something special I need to do to make the Merge() work or is
there something I don't understand correctly with the behaviour of the
Merge() function?
Thanks in advance,
Jonathan