Hi All
This sound very simple to but here goes..
I have a xml file that has multiple nodes with sub-nodes and need to take that info and write it to a SQL table. Using the SQLClient namespace would be the easiest to do a Insert Into the table once I have the data from the XML nodes.
How would it be possible for me to get a handle on those values in the xml file and manipulating them before I write them to a SQL table?
Thanks,
Peter IsherePosted May 28, 2008, 10:38 AM
Thanks for the reply.
I will post again once I bump into something.
Mahesh ChandPosted May 28, 2008, 9:54 AM
1. You need to know how to read an XML document and convert it into an object such as a DataSet or string values or whatever. Here is an article on it: http://www.c-sharpcorner.com/UploadFile/mahesh/ReadWriteXMLTutMellli2111282005041517AM/ReadWriteXMLTutMellli21.aspx
2. After that, you need to know how to insert data to a database table. You can use Stored procedures, DataSet, or an inline SQL for that. Now, it depends on how large data you have in your XML file. If there are a few nodes, you simply can extract values from the XML file node by node using the above method and execute SQL or SP line by line insert. If you want to insert all data once, you may use SqlDataAdapter.Update method. This site has many samples on DataSet update. Search site for Updated DataSet using DataAdapter to get some results.