I recently came to know the concept of 'connection pooling' in .NET, and as such I have a little doubt I would like anyone to clarify it for me. If I use the following piece of code, when will the database connection be returned to the pool so that it can be used by another part of the application?
using (SqlConnection NewConnection = new SqlConnection(ConnectionString))
{
using (SqlCommand NewCommand = new SqlCommand("SomeCommand", NewConnection))
{
try
{
NewConnection.Open();
// Do some work...
NewConnection.Close(); // <-- Here?
}
catch
{
// Error handling...
}
}
}
// <-- Here?
Thank you very much.