Bug #57256 MySQL ODBC Connector 5.1.7 VBA DBEngine.RegisterDatabase
Submitted: 5 Oct 2010 16:45 Modified: 29 Aug 2012 13:36
Reporter: John Torgersen Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.1.7 OS:Windows (XP)
Assigned to: Assigned Account CPU Architecture:Any
Tags: ODBC, regression, VBA, windows

[5 Oct 2010 16:45] John Torgersen
Description:
The VBA DBEngine.RegisterDatabase method that was working under 3.51 and 5.1.6 seems to be not working again under 5.1.7. It failed on my Windows XP machines.

Manual creation of the DSN resulted in the behavior reported in:

http://bugs.mysql.com/bug.php?id=56233

Application of the fix (new .dll) from the report above allowed the DBEngine.RegisterDatabase method to create the DSN with the correct driver, and pass the name, but none of the attributes where passed.

How to repeat:
-Install MySQL ODBC Connector 5.1.7.
Run the VBA function below, which is supposed to create the DSN, to connect to any existing MySQL database. Make sure that you use a new DSN name.

It should fail. Mine had an "ODBC -- call failed.3146" error message.

-Install the new .dll from the bug above.
Run the VBA function again. This time it should create the user DSN, using the correct driver and name, but with no attributes.

Public Function func_build_dsn() As Boolean
    On Error GoTo func_build_dsn_err
    
    strDBname = "database name"
    strServer = "mysql server"
    strPW = "password"
    strUName = "user name"
    strDriver = "MySQL ODBC 5.1 Driver"
    strDSN = "dsn name"
    
    Dim strAttrib As String
    strAttrib = "DESCRIPTION=Link to MySQL" & Chr$(13) & _
            "DATABASE=" & strDBname & Chr$(13) & _
            "UID=" & strUName & Chr$(13) & _
            "PWD=" & strPW & Chr$(13) & _
            "SERVER=" & strServer
            
    Call DBEngine.RegisterDatabase(strDSN, strDriver, True, strAttrib)
    
    func_build_dsn = True
    
func_build_dsn_exit:

    Exit Function
    
func_build_dsn_err:

    func_build_dsn = False
    MsgBox "func_build_dsn encountered an unexpected error: " & Err.Description & Err.Number
    
    GoTo func_build_dsn_exit

End Function

Suggested fix:
Slightly amend the patch in previous bug report to make sure that attributes are also processed, then push out as soon as possible.

Thank you for the hard work.
[5 Oct 2010 20:42] Lawrenty Novitsky
Thank you John!
we will need to verify that though.
[6 Oct 2010 8:58] Bogdan Degtyariov
Verified using revision 932: DSN is created, but all attributes are empty
[19 Jan 2012 19:24] John Torgersen
I just tried version 5.1.9, and it doesn't seem to accept the UID nor PWD.
[29 Aug 2012 13:36] John Torgersen
Just tried with version 5.1.11, and still not working. Is there an alternative that would allow me to create the DSN via MS Access VBA?