Multiple choice technology web technology

Which of the following ways can you proactively clean up a database connection's resources?

  1. Execute the DbConnection object's Cleanup method.

  2. Assign Nothing (C# null) to the variable that references the DbConnection object.

  3. Execute the DbConnection object's Close method.

  4. Execute the DbConnection object's Disconnect method.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

DbConnection objects provide a Close() method to properly close the connection and release database resources. Simply nulling the reference doesn't close the connection (it may remain open until garbage collection), and there are no built-in Cleanup or Disconnect methods. Best practice is using 'using' statements or explicitly calling Close()/Dispose().