What happens to an unclosed database connection?

.net, database-connection

Solution

The connection will close when the application exits. Read up on SqlConnection's Finalize. From MSDN's documentation for Object.Finalize:

"During shutdown of an application domain, Finalize is automatically called on objects that are not exempt from finalization, even those that are still accessible."

Problem

Earlier today I've found a bug in one of our projects - there is a conenction with database that is never closed, i mean the Close() method is never called. However, when I close the application, the connection is closed (checked in sql management studio many times). Why?

Original source