XML into SQL 2005 Express using VB 2005

  • Thread starter Thread starter dfournine
  • Start date Start date
D

dfournine

Hi
I am newbie when it comes to this so please be gentle. What I want to
do is read in data from XML files (1 contains on 1 record per file the
other can contain upward of 500 records) and then write the data out to
SQL 2005 Express. The xml file names will be variable but always read
from the same location then moved once processed. Any pointers on howto
do this or links to articles that describe how to do this type of thing
in VB 2005.

Thanks

D49
 
D49,

The most easiest way to read XML files in Net is as they are readable as
DataSets.

I am not known with Epress, but you can try that by opening your XML file in
Solution Explorer from Express and than to drag it on your workplace.

If that goes and you see a table, than you can read it with
dim ds as dataset
ds.readxml("thepath").

If that is impossible than is the next step the XMLNodeReader.

If that does not go the common Document Load is usable, but that is the
hardest one to use.

I hope this helps sofar,

Cor
 
What Cor posted is correct but just to clairify....

Since the file names vary you can get it like this:

Private Sub LoadFiles()

Dim DsData As New DataSet
Dim Files() As String
Dim File As String
Dim dtTable As DataTable
Dim drRow As DataRow

Files = IO.Directory.GetFiles("C:\DirectoryPath")

For Each File In Files
dsData.ReadXml(File)
Next

For Each dtTable In dsData.Tables
For Each drRow In dtTable.Rows
'This is where you'll update your database with row
data.
Next
Next
End Sub

Hope this helps.
 
Back
Top