C
csharper
I see some people explicitly call the Close method of the
SqlConnection object in a using block. See below:
using (SqlConnection connection = new SqlConnection())
{
connection.ConnectionString = myConnectionString;
connection.Open();
// Do something;
connection.Close(); // <-- Is this necessary?
}
I don't quite understand the explicit call of connection.Close(). I
am sure it is not necessary, but does it do anything in particular?
Thank you.
SqlConnection object in a using block. See below:
using (SqlConnection connection = new SqlConnection())
{
connection.ConnectionString = myConnectionString;
connection.Open();
// Do something;
connection.Close(); // <-- Is this necessary?
}
I don't quite understand the explicit call of connection.Close(). I
am sure it is not necessary, but does it do anything in particular?
Thank you.