?
Solved

Importing XML files into SQL Server 2000 tables

Posted on 2009-05-13
2
Medium Priority
?
409 Views
Last Modified: 2013-11-26
I am new to vb.net and importing the data in the xml documents into a sql tables.  I am wondering the best to approach this project.  The xml files that I need to import into a sql table will be in one folder.  So I am unsure on how to process the first file in the folder move the data into my sql table then move on to the next file until all the data on the xml files has been imported into my sql table.  Can anyone point me in the direction of how to code it properly so all xml files in the directory are read and also an example of how to take those xml fields and import them into my sql table?  Please advise.
0
Comment
Question by:v4seasons
1 Comment
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 1000 total points
ID: 24382326
Its not a 250 points question but anyway try using this code.

Note that you would have a dbconnection already open and a dbcmd as sqlcommand already configured.
Dim dTable as new DataTable
For each File in io.directory.getfiles("C:\XML")
    dTable.ReadXML(File)
    for i as integer = 0 to dTable.rows.count - 1
        dbcmd.commandtext = "Insert Into Table(column1, column2, ...) Values('" & dTable.rows(i).item(0) & "', '" & dTable.rows(i).item(1) ...
        dbcmd.executenonquery()
    next
    dTable.Clear()   
Next

Open in new window

0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month17 days, 6 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question