471,618 Members | 1,514 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,618 software developers and data experts.

Best way to save a datatable into SQL server

Hi,

I have a datatable object in memory, the datasource is not from SQL server.
I want to save this datatable into SQL server 2000, what is the best way to
do it?

The only way I know is to create table dynamically then loop thru datatable
generate and execute an insert statement per row. Quite tedious.

TIA
Jan 19 '06 #1
1 2610
John,

You might have to create the table dynamically, but once you do that,
you should be able to create a SqlDataAdapter and pass the table to the
adapter with the InsertCommand set.

You will probably have to call the SetAdded method on each row of the
data table to set the row state to added (in case it was not), so that the
adapter will recognize the state as being changed.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John" <so*****@microsoft.com> wrote in message
news:OT**************@tk2msftngp13.phx.gbl...
Hi,

I have a datatable object in memory, the datasource is not from SQL
server. I want to save this datatable into SQL server 2000, what is the
best way to do it?

The only way I know is to create table dynamically then loop thru
datatable generate and execute an insert statement per row. Quite tedious.

TIA

Jan 19 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Rob | last post: by
reply views Thread by jimmyfo | last post: by
7 posts views Thread by Steve | last post: by
3 posts views Thread by Kevin | last post: by
reply views Thread by leo001 | last post: by
1 post views Thread by ZEDKYRIE | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.