B
Brandon Olson
Hello all,
I am trying to import a tab delimited text file with 80 columns and 1700
records into a SQLExpress database using vb.net. Here's how I am doing it:
Dim i as Integer = 0 ' Counter
Dim da as New OleDbDataAdapter("SELECT * FROM [format1.txt]",
textFileConnectionString)
dim dt as new DataTable("FromTable")
dim sqlDt as new dataTable("ToTable")
Dim myDataRow as DataRow
da.Fill(dt)
dim sqlDa as new SqlDataAdapter("SELECT * FROM toTable"),
sqlConnectionString)
sqlDa.Fill(sqlDT)
For each myDataRow in dt.Rows
sqlDT.Rows.Add(dt.Rows(i).ItemArray)
'I use this to see if the data was actually written to the new Sql table
' This actually works
Console.WriteLine("fromTable Column(0) - " &
dt.Rows(i).Item(0).ToString)
Console.Writeline("toTable - & Column(0) - " &
sqldt.Rows(i).Item(0).ToString)
' I have tried sticking a sqlDT.AcceptChanges() here - doesn't work
' I have tried sticking a sqlDA.Update(sqlDT) here - doesn't work
i+=1
Next
....etc.
This code appears to working, the sqlDT has the new data in it and is
printing to the console, however, when I look in the Server Manager, no data
appears.
What am I missing?
Thanks in advance,
Brandon
I am trying to import a tab delimited text file with 80 columns and 1700
records into a SQLExpress database using vb.net. Here's how I am doing it:
Dim i as Integer = 0 ' Counter
Dim da as New OleDbDataAdapter("SELECT * FROM [format1.txt]",
textFileConnectionString)
dim dt as new DataTable("FromTable")
dim sqlDt as new dataTable("ToTable")
Dim myDataRow as DataRow
da.Fill(dt)
dim sqlDa as new SqlDataAdapter("SELECT * FROM toTable"),
sqlConnectionString)
sqlDa.Fill(sqlDT)
For each myDataRow in dt.Rows
sqlDT.Rows.Add(dt.Rows(i).ItemArray)
'I use this to see if the data was actually written to the new Sql table
' This actually works
Console.WriteLine("fromTable Column(0) - " &
dt.Rows(i).Item(0).ToString)
Console.Writeline("toTable - & Column(0) - " &
sqldt.Rows(i).Item(0).ToString)
' I have tried sticking a sqlDT.AcceptChanges() here - doesn't work
' I have tried sticking a sqlDA.Update(sqlDT) here - doesn't work
i+=1
Next
....etc.
This code appears to working, the sqlDT has the new data in it and is
printing to the console, however, when I look in the Server Manager, no data
appears.
What am I missing?
Thanks in advance,
Brandon