views:

287

answers:

2

I wanted to know what would be the easiest / best way to get a dataset contained within a datagridview into a sql database.

Points to note:

The data comes from a CSV file that is imported into the application. The user then has the option to modify cell data They then press a button and hopefully upload to sql table It is given that the collum names will all match and the datatypes should match too. Commands will only be insert. no delete or update.

LINQ is ok too.

A: 

You can use SQLBulkcopy. It can take a Datatable and then upload the content to to a SQL Server database.

no_one
+1  A: 

Some info here and http://aspalliance.com/1107 to populate a dataset with a csv. Once you've done that you could use a DataAdapter to write it to SQL.

Another thought. I used to so this manually but you could do it via an SP I think. In the SP call OpenRowSet and read the data straight in the sql code.

Preet Sangha