Insert DataTable or Dataset in to database

R

Ruslan Shlain

I can have a data table or dataset with 3000 + rows in it. I have no
problems getting ether one. Is there a way to insert it in to the SQL server
database with out going through datatable row by row? The datatable will
have exactly the same structure as database table. I have more then 70
columns that i get. Any code samples or links would be great. Thank you all
very much
 
M

Miha Markic

Hi Ruslan,

You should really take a look at DataAdapter class and its derived classes.
It does exactly that - once you've defined InsertCommand and perhaps Update
and DeleteCommand (if you need them) you can do something like:
adapter.Update(table);
 
R

Ruslan Shlain

Problem is, I have 70 + columns and i dont want to define a parametre for
each one of them. Is there a way to automate it? Am i even on the right
track with this?
 
M

Miha Markic

Hi Ruslan,

There is CommandBuilder class you might use it at run-time or you can create
an adjacent adapter at design time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top