How do I update certain rows in a dataset and remerge into original?
Posted on 2009-02-23
I have 1 large dataset, where certain rows can 'match'. Users can modify any of the rows, but if they hit 'auto-match', I combine the matched rows, delete the extra row, then post to the database. Other rows that are linked to the matched row also get posted to the database. Then I want to combine everything back into 1 dataset.
Job 1-1, Match = Y, modified = N
Job 1-2, Match = N, modified = Y
Job 2-1, match = N, modified = N
Job 2-2, match = N, modified = Y
* User hits 'automatch'
I pull all changed records into a dataset (dsChange - now contains Job 1-2 and 2-2), and set dsMain.ApplyChanges to clear all rowstates since I only want specific data updated
Job 1-1 is combined with it's match, and the match is deleted in dsMain
Job 1-2 is marked to be updated
Changes are posted to the db - dsMain.Update()
Now I want to reapply the change to Job 2-2, but ignore the change for 1-2, and have a final set of data in dsMain again. The final ds should only show 2-2 as modified.
Currently I am doing the below to have the Main ds take precidence over the changes.
dsMain = dsChange
The problem is that since 1-2 is marked as changed in dsChange, and not changed in dsMain, the final dsMain shows that 1-2 is still changed. There is a timestamp that is updated, so I can tell if the row was updated in the auto-match.
I know this is confusing, please let me know where I need to clarify.