obj_Cnn_Principal.Properties(58).Value RRS feed

  • Question

  • Hello, I am working on a proyect that somebody el did. 

    Now, there is an excel template that request the user to put username and password to connect to a database, using something like:


    Public obj_Cnn_Principal As ADODB.Connection

    Inside a sub: 

    Set obj_Cnn_Principal = New ADODB.Connection

        With obj_Cnn_Principal
            .CursorLocation = adUseServer
            .Provider = "SQLOLEDB.1"
            .ConnectionString = "Database=DBNAME;Data Source=\MyServer;"
            .Properties("Prompt") = adPromptAlways

        End With

    Inside another sub, it have 

    Dim sUsuario As String

    sUsuario = obj_Cnn_Principal.Properties(58).Value

    The issue, this properties(58) get value equal to: select CURRENT_USER; statement

    but I need to get the value equal to: select SYSTEM_USER;

    this is because with some users that have dbo right, they are mark as dbo insted of their correct usernames. 

    I am unable to find the list of such properties, if somebody could help me to find the list of properties number, so I can find the system user insted of current_user, will be apprecieate. 

    Gilberto H.

    Wednesday, November 12, 2014 7:28 PM

All replies

  • Try using a simple For Next Loop to loop through the Properties of that object until it equals "SYSTEM_USER" then you would know what the number is, or maybe use obj_Cnn_Principal.Properties("CURRENT_USER") and obj_Cnn_Principal.Properties("SYSTEM_USER") in lieu of using values. 
    Wednesday, November 12, 2014 7:58 PM