Consulting

Results 1 to 2 of 2

Thread: ODBC connection error through VBA in excel

  1. #1
    VBAX Regular
    Joined
    Jul 2018
    Posts
    12
    Location

    ODBC connection error through VBA in excel

    Hi,

    I have created ODBC connection and trying to test ODBC connection in excel through VB.

    ODBC DSN is tested and working.But when I use same DSN in VB script, it says invalid user name/password error.

    Can any on let me know what is missing here.

    Sub OraConn()
    'Dim cnn As ADODB.Connection
    'Set cnn = New ADODB.Connection
    'Open a Connection using an ODBC DSN

    Dim cnn As Object
    Set cnn = CreateObject("ADODB.Connection")
    cnn.Open "D_DSN", "ro_user", "xxxx"


    If cnn.State = adStateOpen Then
    MsgBox "Welcome"
    Else
    MsgBox "Sorry."
    End If

    ' Close the connection.
    cnn.Close
    End Sub


    Thanks in advance

  2. #2
    Turn on the macro recorder and then manually connect to that connection. That should get you the syntax (more or less).
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •