Do I have to Close() a SQLConnection before it gets disposed?
问题 Per my other question here about Disposable objects, should we call Close() before the end of a using block? using (SqlConnection connection = new SqlConnection()) using (SqlCommand command = new SqlCommand()) { command.CommandText = \"INSERT INTO YourMom (Amount) VALUES (1)\"; command.CommandType = System.Data.CommandType.Text; connection.Open(); command.ExecuteNonQuery(); // Is this call necessary? connection.Close(); } 回答1: Since you have a using block, the Dispose method of the SQLCommand