I am building the connection treatment and this question came to mind, even though I could not find a satisfactory answer. So I came here to ask the most experienced programmers.
Is there any possibility that when a exception is thrown a SqlConnection
already opened is closed because of this exception ?
Illustrative code:
SqlConnection con = new SqlConnection(connectionString);
try
{
con.Open();
//algum código aqui....
}
catch (Exception)
{
//possibilidade de fechamento da conexão? .....
throw;
}