P
Paul Delcogliano
Hi All,
I think I am mis-understanding something about the DataSet's Merge method. I
am getting changes from my DataSet and storing them in another DataSet
called changes. I then pass those changes to the UpdateDataset method of the
Data Access Application Block. Any new rows in the changes dataset are
inserted into my SQL Server db and the new ID value from the database is
assigned to the added rows in the changes dataset.
Now, I want to merge my changes back into my original dataset. When I call
the Merge method, the new rows are not merged so much as they are added. So
what I end up with is 2 copies of the new row. Reading through the
documentation, it sounds like this is the expected behavior since the
original new row in the dataset has a primary key value different that the
primary key value that came back from the database. In my case, when I add a
new row to the dataset, I set the primary key value to a negative number,
i.e. -1. Then when after the database insert occurs, the -1 is replaced with
a new identity value from the database. Naturally, the two don't match.
My question is this, how do I force the two rows to match so that the merge
updates the dataset correctly with the new id value returned from the db?
Any insight is greatly appreciated,
Paul
I think I am mis-understanding something about the DataSet's Merge method. I
am getting changes from my DataSet and storing them in another DataSet
called changes. I then pass those changes to the UpdateDataset method of the
Data Access Application Block. Any new rows in the changes dataset are
inserted into my SQL Server db and the new ID value from the database is
assigned to the added rows in the changes dataset.
Now, I want to merge my changes back into my original dataset. When I call
the Merge method, the new rows are not merged so much as they are added. So
what I end up with is 2 copies of the new row. Reading through the
documentation, it sounds like this is the expected behavior since the
original new row in the dataset has a primary key value different that the
primary key value that came back from the database. In my case, when I add a
new row to the dataset, I set the primary key value to a negative number,
i.e. -1. Then when after the database insert occurs, the -1 is replaced with
a new identity value from the database. Naturally, the two don't match.
My question is this, how do I force the two rows to match so that the merge
updates the dataset correctly with the new id value returned from the db?
Any insight is greatly appreciated,
Paul