R
Ruslan Shlain
I am pulling data from flat file and putting it in to the DB using dataset.
Below i am including code how i did it. I am adding a row to a new table in
the dataset and adding collumns to it one by one. The reson i did it this
way is because i need to have column changed in order for Update to work. Is
there a better way to do it? I am looking to cut proccesing time.
Thank you all very much.
Dim FilePath As String = "C:\ftproot\TOG\"
Dim Conn As New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & FilePath & ";Extended Properties=""text;HDR=NO;FMT=Delimited""")
Dim Comm As New System.Data.OleDb.OleDbDataAdapter("select * from
c126927_1_sc_011504_001.txt", Conn)
Dim DS As New DataSet
Try
Comm.Fill(DS)
Dim dr As DataRow
Dim dt As DataTable
dt = DS.Tables(0).Clone
dt.TableName = "scs_ds_sold_customer"
Dim newdr As DataRow
Dim dc As DataColumn
DS.Tables.Add(dt)
For Each dr In DS.Tables(0).Rows
newdr = DS.Tables(1).NewRow
For Each dc In DS.Tables(0).Columns
newdr.Item(dc.ColumnName) = dr.Item(dc.ColumnName)
Next
DS.Tables(1).Rows.Add(newdr)
Next
Dim objCn As New
SqlConnection("Server=NTCH27;Database=scs_auto_menu;Trusted_Connection=True;
")
Dim NwindDA As New SqlDataAdapter("select * from scs_ds_sold_customer",
objCn)
Dim x As SqlCommandBuilder = New SqlCommandBuilder(NwindDA)
objCn.Open()
NwindDA.Update(DS, "scs_ds_sold_customer")
Catch e As Exception
End Try
Below i am including code how i did it. I am adding a row to a new table in
the dataset and adding collumns to it one by one. The reson i did it this
way is because i need to have column changed in order for Update to work. Is
there a better way to do it? I am looking to cut proccesing time.
Thank you all very much.
Dim FilePath As String = "C:\ftproot\TOG\"
Dim Conn As New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & FilePath & ";Extended Properties=""text;HDR=NO;FMT=Delimited""")
Dim Comm As New System.Data.OleDb.OleDbDataAdapter("select * from
c126927_1_sc_011504_001.txt", Conn)
Dim DS As New DataSet
Try
Comm.Fill(DS)
Dim dr As DataRow
Dim dt As DataTable
dt = DS.Tables(0).Clone
dt.TableName = "scs_ds_sold_customer"
Dim newdr As DataRow
Dim dc As DataColumn
DS.Tables.Add(dt)
For Each dr In DS.Tables(0).Rows
newdr = DS.Tables(1).NewRow
For Each dc In DS.Tables(0).Columns
newdr.Item(dc.ColumnName) = dr.Item(dc.ColumnName)
Next
DS.Tables(1).Rows.Add(newdr)
Next
Dim objCn As New
SqlConnection("Server=NTCH27;Database=scs_auto_menu;Trusted_Connection=True;
")
Dim NwindDA As New SqlDataAdapter("select * from scs_ds_sold_customer",
objCn)
Dim x As SqlCommandBuilder = New SqlCommandBuilder(NwindDA)
objCn.Open()
NwindDA.Update(DS, "scs_ds_sold_customer")
Catch e As Exception
End Try