How do I update my SQL database using XML?
I have the following XML file:
<?xml version="1.0" encoding="utf-8"?>
<Patients>
<Patient EMail="LeBron@James.com">
<FirstName>LeBron</FirstName>
<LastName>James</LastName>
</Patient>
<Patient EMail="Kobe@Bryant.com">
<FirstName>Kobe</FirstName>
<LastName>Bryant</LastName>
</Patient>
<Patient EMail="Allen@Iverson.com">
<FirstName>Allen</FirstName>开发者_如何转开发
<LastName>Iverson</LastName>
</Patient>
</Patients>
I want to store it in a SQL database which I have done successfully/
I then added some more data to the same XML File:
<?xml version="1.0" encoding="utf-8"?>
<Patients>
<Patient EMail="LeBron@James.com">
<FirstName>LeBron</FirstName>
<LastName>James</LastName>
</Patient>
<Patient EMail="Kobe@Bryant.com">
<FirstName>Kobe</FirstName>
<LastName>Bryant</LastName>
</Patient>
<Patient EMail="Allen@Iverson.com">
<FirstName>Allen</FirstName>
<LastName>Iverson</LastName>
</Patient>
<!-- New data starts here -->
<Patient EMail="trtr@Iverson.com">
<FirstName>tr</FirstName>
<LastName>rson</LastName>
</Patient>
<Patient EMail="wewn@Iverson.com">
<FirstName>Awerwren</FirstName>
<LastName>Iveww</LastName>
</Patient>
</Patients>
But it does not update in SQL database at runtime.....
What am I doing wrong?
Based on what you've posted, I'm guessing that perhaps there's a primary or unique key on the Patient table's FirstName and LastName columns, and the second time you try to insert data into the database this constraint is causing the inserts to fail.
Just a guess. Post more information and perhaps we can narrow it down a bit for you.
Share and enjoy.
Delete the previous database. Create a new database with the new XML.
精彩评论