8
ฉันต้องปิด () การเชื่อมต่อ SQLC ก่อนที่จะถูกกำจัดหรือไม่?
สำหรับคำถามอื่น ๆ ของฉันที่นี่เกี่ยวกับ Disposable objectsเราควรเรียก Close () ก่อนสิ้นสุดบล็อกการใช้งานหรือไม่ 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(); }