Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Update DataBase from xml file

Update DataBase from xml file

Scheduled Pinned Locked Moved Database
csharpdatabasexmltutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mr Candyman
    wrote on last edited by
    #1

    Please, I need to know how to read xml document (created with dataSet.WriteXml) with ado.net 2.0 and update the corresponding table in the database with those values. I wrote this test code:using (DataSet ds = new DataSet()) using (SqlConnection conn = new SqlConnection(connectionString)) using (SqlDataAdapter da = new SqlDataAdapter("select * from TableName", conn)) { try { da.Fill(ds); ds.ReadXml(@"C:\xmldataset.XML"); ds.AcceptChanges(); da.Update(ds); } [...]
    Nevertheless, the values in the database haven't been modified, after. What am I missing? Thanks in advance.

    A 1 Reply Last reply
    0
    • M Mr Candyman

      Please, I need to know how to read xml document (created with dataSet.WriteXml) with ado.net 2.0 and update the corresponding table in the database with those values. I wrote this test code:using (DataSet ds = new DataSet()) using (SqlConnection conn = new SqlConnection(connectionString)) using (SqlDataAdapter da = new SqlDataAdapter("select * from TableName", conn)) { try { da.Fill(ds); ds.ReadXml(@"C:\xmldataset.XML"); ds.AcceptChanges(); da.Update(ds); } [...]
      Nevertheless, the values in the database haven't been modified, after. What am I missing? Thanks in advance.

      A Offline
      A Offline
      Adeel Chaudhry
      wrote on last edited by
      #2

      Hi, The point you are missing is to insert the data read from XML file. Check this out: http://www.codeproject.com/cs/database/generic_OpenXml.asp[^] http://www.codeproject.com/cs/database/insxmldatasqlsvr.asp[^] http://technet.microsoft.com/en-us/library/ms171806.aspx[^] and also try googling "xml bulk load" Regards, Adeel

      Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.

      M 1 Reply Last reply
      0
      • A Adeel Chaudhry

        Hi, The point you are missing is to insert the data read from XML file. Check this out: http://www.codeproject.com/cs/database/generic_OpenXml.asp[^] http://www.codeproject.com/cs/database/insxmldatasqlsvr.asp[^] http://technet.microsoft.com/en-us/library/ms171806.aspx[^] and also try googling "xml bulk load" Regards, Adeel

        Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.

        M Offline
        M Offline
        Mr Candyman
        wrote on last edited by
        #3

        Thanks a lot, but I thought the dataset could do it, why is the ReadXml method for then, if you can open the xml like a XmlDocument?

        A 1 Reply Last reply
        0
        • M Mr Candyman

          Thanks a lot, but I thought the dataset could do it, why is the ReadXml method for then, if you can open the xml like a XmlDocument?

          A Offline
          A Offline
          Adeel Chaudhry
          wrote on last edited by
          #4

          Hi, For knowing that in detail, you may find the following useful: http://msdn2.microsoft.com/en-us/library/system.data.dataset.readxml.aspx[^] http://msdn2.microsoft.com/en-us/library/aa325639(VS.71).aspx[^] Regards, Adeel

          Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups