Solved

Importing XML files into SQL Server 2000 tables

Posted on 2009-05-13
2
400 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
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 250 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

777 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