The State property allows you to determine whether a connection is open, closed, connecting, or executing a command. The value will be a bit mask containing one or more of the following ObjectStateEnum constants:
□ adStateClosed — The connection is closed
□ adStateOpen — The connection is open
□ adStateConnecting — The object is in the process of making a connection
□ adStateExecuting — The connection is executing a command
If you attempt to close a Connection object that is already closed, you will cause an error. You can prevent this from occurring by testing the state of the Connection object before closing it:
If CBool(objConn.State And adStateOpen) Then objConn.Close
Was this article helpful?