When mergint dataset, edited rows getting added once again.

  • Thread starter Thread starter Bibin
  • Start date Start date
B

Bibin

Dear All,

I am developing an application in .Net. I put one Business Logic Layer and
one Database Layer.

In the user interface I will be picking all the records, will be editing.
then I will pass the edited dataset to the business Layer.

In the Business Layer, It will be taking the changed records using
Dataset.GetChanges() Method.

After updating the dataset, I will be merging the changed cataset with the
original One.

When merging, I am getting more rows in the original Dataset. That means
when merging the dataset, the edited rows are comming
as new rows in the dataset.

Y it is comming like that. If anybody having any idea, please reply.

Regards,

Bibin.
 
Hi Bibin,

Yes, you are right. That is a problem.
It happens because merge uses pks to match the rows and the updated rows
(from GetChanges) have a new id (retrieved from database) that doesn't match
old code autogenerated ids.
I suggest that before updating GetChanges to database you'll have to store
pairs of new rows from old table-new table.
After you are done with update you'll have to refresh old table new rows id
with new table ones (you can match them through pairs stored before). Don't
forget to unset readonly field of id before updating.
 
Back
Top