Link to home
Start Free TrialLog in
Avatar of stwokie
stwokie

asked on

Need help using tableadapter update to save imported xml data back to sql server compact 3.5 database.

I need to be able to add import/export functionality to an application so that several users can keep their data "sync'ed" up.  The users will never be connected to the same network, and an "online" server is not a feasable option.  

I use a typed dataset for the data application and can write it out to xml.  I thought that perhaps I could use the dataset.ReadXml function and then do an update on the table adapters to get this data into another users database.  

New records are inserted just fine (based on primary keys).  However, how do I get the tableadapter to update the database on changed records.  

Here is the import code:

            loomixDataSet ds = new loomixDataSet();
            string _connstr = Properties.Settings.Default.connstr;
            //ds.EnforceConstraints = false;

            ds.ReadXml("c:\\loomix.xml", XmlReadMode.ReadSchema);

            ProductsTableAdapter prods = new ProductsTableAdapter();
            prods.Connection.ConnectionString = _connstr;
            foreach(DataRow dr in ds.Products)
            {
                try
                {
                    prods.Update(dr);
                }
                catch
                {
                 
                }
            }

I am looking for some code to insert into the catch block to force the table adapter to call the update command instead of an insert command.
ASKER CERTIFIED SOLUTION
Avatar of stwokie
stwokie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial