Releasing the SQLServer Object

When your program is finished with a SQL-DMO object it created, you must release the object. After releasing your last reference to a SQL-DMO object, the object variable is invalid and must not be used. To use the object again you must get a new reference to it.

Visual Basic

To release objects you created using the New keyword of a Dim statement or the CreateObject function, set the object variable to Nothing. For example:

Set oSQLServer = Nothing

Visual Basic will automatically release an object when the object variable goes out of scope.

C++

Use the Release function to release objects you created using the OLE CoCreateInstance function. For example:

pSQLServer->Release();