Adding datatable data to sql database.

  • Thread starter Thread starter Vaibhav
  • Start date Start date
V

Vaibhav

Hello everyone,

I have a datatable with rows read from csv file. Now i want to insert the
data from datatable to database. Datatable has same columns as the table to
which i have to add rows.

Can anyone tell me the way i can achieve this. The datatable is a normal
datatable and not table from a dataset.

Thanks in advance
 
Hi

You can try this:

System.Data.SqlClient.SqlCommandBuilder local_SqlCommandBuilder = new
System.Data.SqlClient.SqlCommandBuilder(local_SqlDataAdapter);
local_SqlCommandBuilder.ConflictOption =
System.Data.ConflictOption.OverwriteChanges;
local_SqlDataAdapter.UpdateCommand =
local_SqlCommandBuilder.GetUpdateCommand();
local_SqlDataAdapter.Update(YourDataTable);

Best regards
Frank Uray
 
Back
Top