I have the following code, If I use conn == null in finally do I still use connection pooling? I know it is a good practice to close your connection but how about disposing the whole connection object?
public void ExecuteNonQuery(SqlCommand Cmd)
{
//========== Connection ==========//
SqlConnection Conn = new SqlConnection(strConStr);
try
{
//========== Open Connection ==========//
Conn.Open();
//========== Execute Command ==========//
Cmd.Connection = Conn;
Cmd.CommandTimeout = 180;
Cmd.ExecuteNonQuery();
}
catch (Exception Exc)
{
throw Exc;
}
finally
{
//======== Closing Connection ========//
if (Conn.State == ConnectionState.Open)
{ Conn.Close(); }
//======== Disposing object ========//
Conn = null;
}
}