0

I'm tryng to find out when my odbc dsn-less connection fails due to invalid user/password, to provide that specific info to user. Right now I get a generic messsage that connection failed, from my vba error handling code.

  • I was able to just see that specific error in odbc trace log...

DIAG [S1000] [MySQL][ODBC 8.0(w) Driver]Access denied for user 'xxxxx'@'pool-173-xxx-xxx

..but how can i get at that error message in my error handling code?

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

  • vba connection code and error handle..

    Function TestLogin(uid As String, pwd As String) As Boolean
    
        On Error GoTo TestError
    
        Dim dbs          As DAO.Database
        Dim qdf          As DAO.QueryDef
        Dim strcon As String
    
        mysqlUser = uid
    
        strcon = "ODBC; Driver=MySQL ODBC 8.0 Unicode Driver;" & _
        "SERVER={accrrrs.cpbo3r0tdggvwertg.us-west-2.rds.amazonaws.com};DATABASE=testdb;PORT=3306;" & _
         "UID=" & uid & "; PWD=" & pwd & ";COLUMN_SIZE_S32=1;DFLT_BIGINT_BIND_STR=1;OPTION=3"
    
    
        Set dbs = CurrentDb()
        Set qdf = dbs.CreateQueryDef("")
    
    
         qdf.Connect = strcon
    
         qdf.ReturnsRecords = False
    
         qdf.sql = "SELECT 1 "
          qdf.Execute
    
         TestLogin = True
         DoCmd.Close
         DoCmd.OpenForm "Switchboard"
    
    exit_errorTrap:
         Exit Function
    
    TestError:
       Dim myerror As DAO.Error
       For Each myerror In DBEngine.Errors
          With myerror
              If .Number <> 3146 Then
                  MsgBox .Description
              End If
          End With
      Next
      Resume exit_errorTrap
    
     End Function
    
donnyc
  • 5
  • 3
  • 1
    Try raising DBEngine errors in your error handler. See [this answer](https://stackoverflow.com/a/24251587/1422451). – Parfait Oct 20 '20 at 21:41
  • thanks @parfait - so i tried that, and now shows error "ODBC - Connection to MYSQL ODBC... failed." but its same message whether no network or bad creds. – donnyc Oct 20 '20 at 22:08
  • Please show your code and attempt unless we take your word for it. – Parfait Oct 20 '20 at 22:14
  • thx - just added above – donnyc Oct 20 '20 at 22:47
  • I still just get a generic "odbc - xxxxx failed" message. In the odbc log however, it does indicate the more specific "access denied.." error. How can i access this error info from odbc? – donnyc Oct 21 '20 at 21:59

0 Answers0