Solved

Importing XML files into SQL Server 2000 tables

Posted on 2009-05-13
2
403 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MYSQL responding very slow 3 50
Access/Visual Basic Question 3 43
Add Combobox column to datagridview using vb.net 2 27
reading an excel file vb.net 2 20
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
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 antispam), the admini…

726 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