first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

VB: ADO; Using the Properties Collection of the Connection Object

I use the Properties Collection of the Connection object to enter custom log information during a database connection. For example the sub LogSession is called (repeatedly) during the ConnectComplete Event:

Private Sub pADOcnn_ConnectComplete(ByVal pError As ADODB.Error, _ adStatus As ADODB.EventStatusEnum, _ ByVal pConnection As ADODB.Connection)

    If adStatus = adStatusOK Then
        Call LogSession("Data Connection established (" _
            & VBA.Now & ")")
        Call LogSession(VBA.Space$(4) _
            & "User ID:                      " _
            & pConnection.Properties.Item("User ID"))
        If pConnection.Provider Like "SQLOLEDB*" Then _
        Call LogSession(VBA.Space$(4) _
            & "Workstation ID:               " _
            & pConnection.Properties.Item("Workstation ID"))
        Call LogSession(VBA.Space$(4) _
            & "Data Source DBMS Name:        " _
            & pConnection.Properties.Item("DBMS Name"))
        Call LogSession(VBA.Space$(4) _
            & "Data Source DBMS Version:     " _
            & pConnection.Properties.Item("DBMS Version"))
        Call LogSession(VBA.Space$(4) _
            & "Data Source Current Catalog:  " _
            & pConnection.Properties.Item("Current Catalog"))
        Call LogSession(VBA.Space$(4) _
            & "Data Source Provider Name:    " _
            & pConnection.Properties.Item("Provider Name"))
        Call LogSession(VBA.Space$(4) _
            & "Data Source Provider Version: " _
            & pConnection.Properties.Item("DBMS Version"))
    ElseIf adStatus = adStatusErrorsOccurred Then
        Call EnvironmentErr(pError)
        Call LogSession("ERROR (" & VBA.Now & "):" _
            & p_strErrMsg)
    End If
End Sub

The Key strings for the Properties Collection is based on MS KB article Q193135 ("INFO: Initialization Properties for SQLOLEDB OLE DB Provider").

mod date: 2000-02-10T06:51:03.000Z