SqlConnection
cn = new SqlConnection
("connection string");
cn.Open();
SqlBulkCopy bulkCopy = new SqlBulkCopy(cn);
bulkCopy.DestinationTableName = "Destination table";
bulkCopy.BatchSize = 100;
try
{
bulkCopy.WriteToServer(DataTableName);
}
catch (Exception ex)
{
throw;
}
finally
{
cn.Close();
cn.Dispose();
}
DataTable to be inserted must have same schema as
destination table
No comments:
Post a Comment