PC Review


Reply
Thread Tools Rate Thread

dataTable to Database

 
 
Bruno Alexandre
Guest
Posts: n/a
 
      15th Nov 2005
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)




 
Reply With Quote
 
 
 
 
=?Utf-8?B?RWx0b24gVw==?=
Guest
Posts: n/a
 
      15th Nov 2005
Try:

For Each row As DataRow In dataTable.Rows
strDate = row("date").ToString
strDesc = row("desc").ToString
sql = ...
Next

HTH

Elton Wang

"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)
>
>
>
>
>

 
Reply With Quote
 
Sahil Malik [MVP]
Guest
Posts: n/a
 
      20th Nov 2005
..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.ma.../13/63199.aspx
----------------------------------------------------------------------------

"Bruno Alexandre" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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)
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Compare DataTable Row vs Database Row? Cor Ligthert[MVP] Microsoft ADO .NET 0 19th Mar 2009 07:37 AM
updating database using datatable joel Microsoft Dot NET 1 19th Sep 2007 02:27 PM
Add new DataTable to a database??? fiaolle Microsoft VB .NET 1 9th Jul 2006 06:57 PM
DataTable to Database Bruno Alexandre Microsoft Dot NET Framework Forms 0 15th Nov 2005 04:22 PM
From DataTable to SQL database Joshua Campbell Microsoft VB .NET 2 15th Dec 2004 03:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:18 PM.