Best way to "update" existing records in Dataset bound to XML
I am creating an app with a XML data store. One of the tables in the data store is "Parameters".
There are many parameters to one master record. I have the master record bound to a WinForm and am able to add edit records.
I want to be able to let users edit "parameters" which I have a DataGridView for them to edit/add/delete them with.
I am having trouble mapping existing parameters in the datastore to the DataGridView. For example:
Parameter Age = 12
When I load up the DataGridView it has the Age = 12, but when I change it to 15 or something and save - I end up with 2 parameter records in my store instead of an updated record.
I am trying to fill a data table from the DataGridView, 开发者_如何转开发and merge it into my XML data store - but merge is not working like I thought it would. If the primary key is the same why is it adding a new record instead of updating? Am I going about this wrong?
Thanks!
Are you keeping all your data loaded into a dataset? Datasets have objects can be easily treated as a sql table and they serialize into xml file correctly.
If I did an app with XML store I would leave the low-level file managament to the DataSet class.
精彩评论