tags:

views:

78

answers:

2

I have the following XML file:

<?xml version="1.0" encoding="utf-8"?>
<Patients>
  <Patient EMail="[email protected]">
    <FirstName>LeBron</FirstName>
    <LastName>James</LastName>
  </Patient>
  <Patient EMail="[email protected]">
    <FirstName>Kobe</FirstName>
    <LastName>Bryant</LastName>
  </Patient>
  <Patient EMail="[email protected]">
    <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="[email protected]">
    <FirstName>LeBron</FirstName>
    <LastName>James</LastName>
  </Patient>
  <Patient EMail="[email protected]">
    <FirstName>Kobe</FirstName>
    <LastName>Bryant</LastName>
  </Patient>
  <Patient EMail="[email protected]">
    <FirstName>Allen</FirstName>
    <LastName>Iverson</LastName>
  </Patient>
  <!-- New data starts here -->
  <Patient EMail="[email protected]">
    <FirstName>tr</FirstName>
    <LastName>rson</LastName>
  </Patient>
  <Patient EMail="[email protected]">
    <FirstName>Awerwren</FirstName>
    <LastName>Iveww</LastName>
  </Patient>
</Patients>

But it does not update in SQL database at runtime.....

What am I doing wrong?

A: 

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.

Bob Jarvis
Yes Primary Key is there in Table...Solution?
DevKk
I am thinking the same thing. If we are wrong, post more details about any SQL errors you receive or stack trace of an exception that pops up.
Dick Lampard
@Kumar: if there is a primary key on the FirstName and LastName columns you won't be able to insert the same names multiple times. The solution is either to remove the data before trying to re-insert it, or to change your code to do an UPSERT or MERGE (depending on your database) instead of an INSERT. Good luck.
Bob Jarvis
A: 

Delete the previous database. Create a new database with the new XML.

Geoffrey Van Wyk