|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
dataTable to DatabaseI have a dataTable with 2 columns and several rows... How can I pass this into the Database? How can I read row by row so I can insert it in Database, somthing like for each dataTable.row col1 = .column("date").toString col2 = .column("desc").toString sSQL = "INSERT INTO tblTable (t1, t2) VALUES ('" & col1 & "', '" & col2 & "')" next -- Bruno Alexandre (Sintra, PORTUGAL) Try:
For Each row As DataRow In dataTable.Rows strDate = row("date").ToString strDesc = row("desc").ToString sql = ... Next HTH Elton Wang Show quote "Bruno Alexandre" wrote: > Hi guys, > > I have a dataTable with 2 columns and several rows... > > How can I pass this into the Database? > How can I read row by row so I can insert it in Database, somthing like > > for each dataTable.row > > col1 = .column("date").toString > col2 = .column("desc").toString > > sSQL = "INSERT INTO tblTable (t1, t2) VALUES ('" & col1 & "', '" & col2 > & "')" > > next > > > -- > > > > Bruno Alexandre > (Sintra, PORTUGAL) > > > > > ..NET 1.1 --> DataAdapter with the relevant commands specified.
..NET 2.0 --> SqlBulkCopy -> DataTableReader or simply a DataAdapter (the ..NET 1.1) way. You can also specify BatchSize in .NET 2.0 for better performance. Alternatively, write it out as CSV and import using DTS/SSIS - Sahil Malik [MVP] ADO.NET 2.0 book - http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx ---------------------------------------------------------------------------- Show quote "Bruno Alexandre" <bruno.n***@filtrarte.com> wrote in message news:%23sRkDFg6FHA.2156@TK2MSFTNGP14.phx.gbl... > Hi guys, > > I have a dataTable with 2 columns and several rows... > > How can I pass this into the Database? > How can I read row by row so I can insert it in Database, somthing like > > for each dataTable.row > > col1 = .column("date").toString > col2 = .column("desc").toString > > sSQL = "INSERT INTO tblTable (t1, t2) VALUES ('" & col1 & "', '" & col2 > & "')" > > next > > > -- > > > > Bruno Alexandre > (Sintra, PORTUGAL) > > > > |
|||||||||||||||||||||||