I'm confused with the way Dataset works in ADO.Net, especially when it
comes to dataset merging.
Assuming I have 2 dataset (DS1 and DS2), in which 1 comes from a
SQLServer and the other came from another datasource (eg. Access). If
I were to merge the two Dataset into DS1 and update the dataset into
Access again, I'll get a concurrency constraint error.
Example
DS1 - Source Dataset
DS2 - Target Dataset
Both DS have Table["TestTable"] have Row[0] as their primary key..
DS1 have the following data:
Row[0][1] = "TestingReplace"
Row[1][1] = "TestingNew"
DS2 have the following data:
Row[0][1] = "Testing"
DS2.merge(DS1,true,ignore) will merge the ds1's table into ds2's
table, and the new data will be
DS2's new data:
Row[0][1] (Original Version) = "TestingReplace"
Row[0][1] (Current Version) = "Testing"
Rowstate = modified
Row[1][1] (Original Version) = "TestingNew"
Row[1][1] (Current Version) = "TestingNew"
rowstate = unchanged
If the dataset is now updated using this statement
DS2DataAdapter.update(DS2, "TestTable")
we'll have an error since the original version's value have been
changed! on top of that the new row that's added are not having its
rowstate changed to "Added"
My Questions is:
1. Why does merge changes the original value instead of its current
value?
2. why doesn't the example above change its row rowstate into "Added"?
please help to clarify this...thanks
|