none
How to Load database from dataset saved in XML file such that data common between database and file are updated, new data in xml is added to database RRS feed

  • Question

  • I am trying to
    Load database from dataset saved in XML file such that data common between database and file are updated, new data in xml is added to database

    The scenario is as follows:
    User 1 does updates to database tables and saves the dataset into XML file

    User2 reads the XML file and updates his/her version of the database using the changes user1  made.

    The dataset contains several tables - Some may be changed by user 1

    I am looking for a generic way to do this without trying to check what happened to each record in each table....

    of course a TableAdapter.Update(new.XML) won't work because some records will be duplicate and Update may insert them again.

    Thanks in advance...

    EK-Foreverlearning
    Sunday, June 28, 2009 6:51 PM

Answers

  • How about if you do the following create two of the DataSet's, one with the data from the database, the other with the data from the Xml file. Then just merge the data from the xml file into the data from the database. Below is a link to what merge does

    http://msdn.microsoft.com/en-us/library/h954hh8s.aspx

    It will merge the data based on the primary key so it shouldn't add duplicates only update rows that require update and add ones that need to be added.

    So then after the merge is completed you can then use the TableAdapter to send the updates back to the database. What do you think? Will this work? The only problem I can see is if there is too much data to load into memory.

    Thanks
    Chris Robinson
    Program Manager - DataSet

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Monday, June 29, 2009 3:57 PM