ADODB Connection Object

Was banging my head against the wall a bit tonight trying to close my ADODB.Connection object down cleanly. My mistake was writing something like the following:

If Not objConnection Is Nothing Then objConnection.Close

It seemed that objConnection was both not nothing, and throwing an error about already being closed.

Solution was to check the State property first, so now I have:

If objConnection.State <> adoStateClosed Then objConnection.Close

Leave a Reply

Your email address will not be published. Required fields are marked *