ADO » Connection » Close


Closes a connection.

The Close method is used to close a Connection object and certain associated objects. Closing an Connection object does not delete it from memory. You can later use the Open method to reopen the same Connection.
If there are open RecordSet objects associated with the Connection object being closed, then all of the RecordSet objects are automatically closed. There is also a rollback of all pending changes in the open RecordSet objects. Calling Close while a transaction is in progress will generate an error.
If there is an open Command object associated with the Connection object being closed, the Command object remains open, but its ActiveConnection property is set to Nothing and it loses all association with the closed Connection.
If you have closed an object and you no longer need it, you can set it equal to Nothing which will remove it from memory.


If objConnection.State = adStateOpen Then
End If
Set objConnection = Nothing

See Also: