N
Nick Chakarov
Hi everybody,
I have a problem updating typed dataset with identity columns in it.The
dataset contains parent-children tables and the updates must happen in order
1. update deleted records in children
2. Update modified-added records in parent, children
The code goes like that: let say that MyDataSet is the dataSet under
consideration and all data adapters are setup to refresh the dataset after
update
DataSet deleted = MyDataSet.GetChanges(DataRowState.Deleted);
if (deleted != null) {
DataAdapter1.Update(deleted);
DataAdapter2.Update(deleted) and so on
MyDataSet.Merge(deleted);
}
DataSet added_modified =
MyDataSet.GetChanges(DataRowState.Added||DAtaRowState.Modified);
if (added_modified != null) {
DataAdapter1.Update(deleted);
DataAdapter2.Update(deleted) and so on
MyDataSet.Merge(deleted);
}
MyDataSet.AcceptChanges();
Well, and the end of that process The dataset doubles the added records,
because Merge does not actually merge new added records but adds them again.
So I setup a little sample with Northwind Categories table using VS.NET Data
Form generator to build the form. The behavior is repeatable in the
generated code as well. Initially in the table there are 9 records. After
adding one new record and pressing update button the data set contains 11
instead of 10 records. So apparently Merge does not merge properly or I am
missing something.
Any help is greatly appreciated
TIA
I have a problem updating typed dataset with identity columns in it.The
dataset contains parent-children tables and the updates must happen in order
1. update deleted records in children
2. Update modified-added records in parent, children
The code goes like that: let say that MyDataSet is the dataSet under
consideration and all data adapters are setup to refresh the dataset after
update
DataSet deleted = MyDataSet.GetChanges(DataRowState.Deleted);
if (deleted != null) {
DataAdapter1.Update(deleted);
DataAdapter2.Update(deleted) and so on
MyDataSet.Merge(deleted);
}
DataSet added_modified =
MyDataSet.GetChanges(DataRowState.Added||DAtaRowState.Modified);
if (added_modified != null) {
DataAdapter1.Update(deleted);
DataAdapter2.Update(deleted) and so on
MyDataSet.Merge(deleted);
}
MyDataSet.AcceptChanges();
Well, and the end of that process The dataset doubles the added records,
because Merge does not actually merge new added records but adds them again.
So I setup a little sample with Northwind Categories table using VS.NET Data
Form generator to build the form. The behavior is repeatable in the
generated code as well. Initially in the table there are 9 records. After
adding one new record and pressing update button the data set contains 11
instead of 10 records. So apparently Merge does not merge properly or I am
missing something.
Any help is greatly appreciated
TIA