how to close a database connection

Discussion created by ecohydrologist on Apr 12, 2011
Latest reply on Apr 14, 2011 by ecohydrologist
My understanding in programming is that one should always close "open" databases. Therefore, using VBA how do I close a database connection which I created as follows:

Public Sub DatabaseConnection()
On Error GoTo EH

    'Connect to idb/Oracle geodatabase
    'Determine version of map document
    Dim m_pMxDoc As IMxDocument
    Set m_pMxDoc = Application.Document
    Dim pLayer As ILayer
    Set pLayer = m_pMxDoc.FocusMap.Layer(gi_LayerIndex)
    Dim pFeatureLayer As IFeatureLayer
    Set pFeatureLayer = pLayer
    Dim pFeatureClass As IFeatureClass
    Set pFeatureClass = pFeatureLayer.FeatureClass
    Dim pDataset As IDataset
    Set pDataset = pFeatureClass
    Dim pVersion As IVersion
    Set pVersion = pDataset.Workspace
    Dim ms_Version As String
    ms_Version = pVersion.VersionName
    'Initialize variables for accessing tables in SDE Geodatabase   
    Dim pPropset As IPropertySet
    Set pPropset = New PropertySet
    With pPropset
        .SetProperty "Server", "idb"
    End With
    Dim pWorkspaceFactory As IWorkspaceFactory
    Set pWorkspaceFactory = New SdeWorkspaceFactory
    'Connect to workspace on server   
    Set g_pFeatureWorkspace = pWorkspaceFactory.Open(pPropset, 0)
Exit Sub
EH: MsgBox Err.Description, vbInformation, "Database Connection"
End Sub