Home All Groups Group Topic Archive Search About

Insert all rows from datatable to database

Author
4 Apr 2006 10:35 AM
ypul
How can Ido this ?

I have a datatable/ dataset, which has rows with data in it.
I want to bulk insert all rows from the dataset to database table (having
same table structure).
what is the best way, with out looping through everyrow and inserting into
database.

Thanks

Author
4 Apr 2006 11:39 AM
Otis Mukinfus
On Tue, 4 Apr 2006 11:35:58 +0100, "ypul" <y***@hotmail.com> wrote:

>How can Ido this ?
>
>I have a datatable/ dataset, which has rows with data in it.
>I want to bulk insert all rows from the dataset to database table (having
>same table structure).
>what is the best way, with out looping through everyrow and inserting into
>database.
>
>Thanks
>

INSERT INTO destination (col1, col2)
       SELECT col1, col2
       FROM source

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Author
6 Apr 2006 2:31 PM
ypul
w.r.t what you have written , my source is dataset and my destination is a
database.
How can I write  a query ?
if u can please give a sample code,

Thanks


Show quote
"Otis Mukinfus" <ph***@emailaddress.com> wrote in message
news:6lm43219mqj0k75bfe1jh4tpmt6dll0ukh@4ax.com...
> On Tue, 4 Apr 2006 11:35:58 +0100, "ypul" <y***@hotmail.com> wrote:
>
> >How can Ido this ?
> >
> >I have a datatable/ dataset, which has rows with data in it.
> >I want to bulk insert all rows from the dataset to database table (having
> >same table structure).
> >what is the best way, with out looping through everyrow and inserting
into
> >database.
> >
> >Thanks
> >
>
> INSERT INTO destination (col1, col2)
>        SELECT col1, col2
>        FROM source
>
> Good luck with your project,
>
> Otis Mukinfus
> http://www.arltex.com
> http://www.tomchilders.com

AddThis Social Bookmark Button