HI,
Check out the possibilty of this method too...
Just copy paste the below code and execute in SQL server.
Main Topics
Browse All TopicsHi, i am using vb.net an am hoping to find a quick method of copying data from an xml file i generated into my sql database tables. I have made the table lyout identicle in the xml layout and tables to my my corresponding tables in sql.
thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: dbrckoviPosted on 2009-03-26 at 07:34:19ID: 23990827
Hi!
> > >
You can do this by using XmlDocument object to parse XML file and SqlCommand object to write this data to database.
I'll give you example which loads file c:\aaa\xmlFile.xml and saves the data from it to table 'someTable'.
Xml looks like this:
It contains 3 rows and 4 columns
<?xml version="1.0" encoding="utf-8"?>
<Table>
<Rows>
<Row>
<Column1>1</Column1>
<Column2>aaaa</Column2>
<Column3>02.05.2009.</Column3
<Column4>154</Column4>
</Row>
<Row>
<Column1>2</Column1>
<Column2>bbbb</Column2>
<Column3>02.04.2009.</Column3
<Column4>653</Column4>
</Row>
<Row>
<Column1>3</Column1>
<Column2>cccc</Column2>
<Column3>02.03.2009.</Column3
<Column4>143</Column4>
</Row>
</Rows>
</Table>
And the table in the database looks like this:
col1 int
col2 nvarchar
col3 nvarchar
col4 int
You can adopt the following code to match your XML format and maybe add some error handling.
Select allOpen in new window