In Our project I have used LINQ to SQL for every kind of database interaction. Now from what I know , When I create and use DataContext object : it opens the connection , crates a transaction , perform the query and closes the connection.
Every now and then we are getting Connection pool error on our services and Server.
” The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. “
Any idea ? Am I completely off here ? Is this related to SQL Server itself ?
We are using LINQ , .Net 3.5 and Sql Server 2008
NOTE: NO DATAREADER IS BEING USED ANYWHERE IN SYSTEM.
Thanks
See here:
When should I dispose of a data context
I’m quoting Jon Skeet quoting someone else here, but it was a surprise to me as well, since we ran into a similar issue.
Basically, the mechanics of how the datacontext closes itself aren’t bulletproof. I’ve since taken to closing it manually, which fixed our problem.