How to update a DataSet read from XML file ?

rizwan6feb

Member
Joined
Aug 18, 2008
Messages
8
Programming Experience
Beginner
I am working on an application in VB.NET and MySql. I am getting a duplicate entry for key 1 error. My application goes through the following steps.

1. Populates DataSet from the database.
2. Makes changes in the DataSet
3. Writes the DataSet into XML file using the following statement

VB.NET:
ds.getChanges().WriteXml("file1.xml", XmlWriteMode.WriteSchema)

4. Read the DataSet from the XML file (after restarting the application) using the following code

VB.NET:
ds.ReadXml("file1.xml", XmlReadMode.ReadSchema)

After populating the dataset from XML file, when i update it back in the database, i receive duplicate entry error (even if i only edit existing records)

How can i make sure that only the records which are added, modified or deleted should be updated in the database
 
DataAdapter.Fill(DataSet, TableName)
'Make data changes
DataSet.Tables(TableName).WriteXml(FileName)
 
Can you upload or send me your form file, I'll take a look and see if I can spot the problem.
 
Sample Code

Hi Tom,
My original code connects to online server my sql server. I have created a similar project ( attached with this message). I have put buttons on the form for every action that my application performs. Please go through the following sequence and you will see duplicate records in the database


1. Connect to Database
2. Save DataSet into XML file
3. Close Application
4. Load DataSet from XML file
5. Update the Database

You will see duplicate records, in the database ( you will find database in the Debug folder)
 

Attachments

  • DataSetXML.zip
    69.4 KB · Views: 65

Latest posts

Back
Top