By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,534 Members | 950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,534 IT Pros & Developers. It's quick & easy.

Need a better way

P: n/a
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=Micros oft.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



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


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)




Dim objCn As New
SqlConnection("Server=NTCH27;Database=scs_auto_men u;Trusted_Connection=True;

Dim NwindDA As New SqlDataAdapter("select * from scs_ds_sold_customer",

Dim x As SqlCommandBuilder = New SqlCommandBuilder(NwindDA)


NwindDA.Update(DS, "scs_ds_sold_customer")

Catch e As Exception

End Try
Nov 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.