P
Priya Bange
Guest
Hi Experts,
I am using the below code for loading data into SQL Server and also ensured that connection is closed. Could you please advise if in case I missed something to avoid such errors.
using (SqlConnection cnn = new System.Data.SqlClient.SqlConnection(ctr))
{
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(ctr, SqlBulkCopyOptions.FireTriggers | SqlBulkCopyOptions.CheckConstraints))
{
cnn.Open();
bulkCopy.LoadFromDataTable(dataTable, tableName);
DataTableReader reader = dataTable.CreateDataReader();
bulkCopy.WriteToServer(reader);
cnn.Close();
}
}
Thanks
Priya
Continue reading...
I am using the below code for loading data into SQL Server and also ensured that connection is closed. Could you please advise if in case I missed something to avoid such errors.
using (SqlConnection cnn = new System.Data.SqlClient.SqlConnection(ctr))
{
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(ctr, SqlBulkCopyOptions.FireTriggers | SqlBulkCopyOptions.CheckConstraints))
{
cnn.Open();
bulkCopy.LoadFromDataTable(dataTable, tableName);
DataTableReader reader = dataTable.CreateDataReader();
bulkCopy.WriteToServer(reader);
cnn.Close();
}
}
Thanks
Priya
Continue reading...