What happens when you don’t close your .NET
SqlConnections? Bad stuff. Bad stuff that will inevitably bring your IIS website crumbling down to ashes. Well… something like that. We all know that we should take extra care to always close our DB connections. Right?
But what happens when developers try to get fancy with their DB connections and focus more on being able to re-use open DB connections rather than being safe? Well, the consequences were bestowed upon me a few weeks ago.
Let me explain (briefly) what happened, what could happen to you, and a way to fix it – while maintaining the flexibility of re-using open DB connections and being able to safely use DB transactions from your C# code (using ADO).