Error : all pooled connections were in use and max pool size was reached

  • Thread starter Thread starter Priya Bange
  • Start date Start date
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...
 

Similar threads

P
Replies
0
Views
80
Priya Bange
P
Back
Top