For sake of completeness, this is the correct code to get the DF_DATABASE_DEFAULT_DATABASE (or any DF_DATABASE_*) attribute from managed connections.


Code:
    Function GetDefaultDatabase Returns String
        
        String sDefaultDatabase
        tConnection Conn
        Handle hConnectionHandle

        Get ConnectionIdInfo of ghoConnection "MssqlOrderID" to Conn
        Get ConnectionDatabaseIdHandle of ghoConnection Conn to hConnectionHandle
        
        If (hConnectionHandle) Begin
            
            Get_Attribute DF_DATABASE_DEFAULT_DATABASE of Conn.iDriverIndex hConnectionHandle to sDefaultDatabase
            Showln (SFormat("DF_DATABASE_DEFAULT_DATABASE = %1", sDefaultDatabase))

        End

        Function_Return sDefaultDatabase
        
    End_Function