DebHanleyRI
Programmer
I need to insert into a database from a csv file.
I started by copying the csv file into a data table and that works like a charm - I can step through this and I see the data in the table:
Using sr As System.IO.StreamReader = System.IO.File.OpenText("\\testSv\c$\VRFiles\liveoutputTEMP.csv")
line = sr.ReadLine()
Do While line IsNot Nothing
Dim data() As String = line.Split(","c)
If data.Length > 0 Then
If i = 0 Then
For Each item In data
dt.Columns.Add(New DataColumn())
Next item
i += 1
End If
Dim row As DataRow = dt.NewRow()
row.ItemArray = data
dt.Rows.Add(row)
End If
line = sr.ReadLine()
Loop
End Using
Now I need to take this datatable and insert it into a database - here is my pseudocode:
For each row in table
patient name - column A
patient DOB = column B
etc.....
Next row
Can anyone point me in the right direction please?
not all who wander are lost....
I started by copying the csv file into a data table and that works like a charm - I can step through this and I see the data in the table:
Using sr As System.IO.StreamReader = System.IO.File.OpenText("\\testSv\c$\VRFiles\liveoutputTEMP.csv")
line = sr.ReadLine()
Do While line IsNot Nothing
Dim data() As String = line.Split(","c)
If data.Length > 0 Then
If i = 0 Then
For Each item In data
dt.Columns.Add(New DataColumn())
Next item
i += 1
End If
Dim row As DataRow = dt.NewRow()
row.ItemArray = data
dt.Rows.Add(row)
End If
line = sr.ReadLine()
Loop
End Using
Now I need to take this datatable and insert it into a database - here is my pseudocode:
For each row in table
patient name - column A
patient DOB = column B
etc.....
Next row
Can anyone point me in the right direction please?
not all who wander are lost....