2

I have tried (nearly) everything to isolate the problem, but I am lost.

I have an MS Access application that uses ADODB to interface to a local MySQL database. I copied it to a new computer, but now the output parameters of the stored procedures contain a random value each time (if done via ADODB). When executed in MySQL WorkBench, the output parameters are correct.

Here are the specs of the 2 computers:

  1. old: Windows 7 Pro, Office 2010 ProPlus, MySQL ODBC 5.3.4, MySQL server 5.6.22 (all are 64-bit; 32-bit ODBC is also installed);
  2. new: Windows 10 Pro, Office 2016 ProPlus, MySQL ODBC 5.3.6, MySQL server 5.7.16 (all are 64-bit, except MS Office; 32-bit ODBC is also installed).

To isolate the problem, I used the following simple stored procedure:

CREATE PROCEDURE `testit`(
    OUT iTest INT(11))
BEGIN
    SET iTest = 123;
END

And a test MS Access database containing only the following VBA code (and a reference to the Microsoft ActiveX Data Objects 6.1 library):

Public Function dbTestIt() As Long

Dim dbConn As ADODB.Connection
Dim dbCmd As ADODB.Command

    'Open new connection
    Set dbConn = New ADODB.Connection
    dbConn.ConnectionString = "Driver={MySQL ODBC 5.3 Ansi Driver};option=3;database=xxx;user=root;password=yyy;"
    dbConn.Open

    'Execute new command
    Set dbCmd = New ADODB.Command
    With dbCmd
        Set .ActiveConnection = dbConn
        .CommandTimeout = 0
        .CommandType = adCmdStoredProc
        .CommandText = "testit"
        .Parameters.Append dbCmd.CreateParameter("iTest", adInteger, adParamOutput)
        .Execute
        dbTestIt = dbCmd.Parameters.Item(0).Value
    End With

    'Close Connection
    dbConn.Close

End Function

Here are the test results:

  1. On the old computer, dbTestIt() always returns 123;
  2. On the new computer, dbTestIt() returns random values (e.g. 51, 1936020585, 1);
  3. And if I connect from the new computer to the MySQL server on the old computer (using server=192.168.1.x in the connection string), it always returns 123 as well;
  4. This tells me the problem is (only) in the MySQL server on the new computer (right?);
  5. However, if I then connect from the old computer to the MySQL server on the new computer, it also always returns 123!

So the problem seems to be in the combination of the components on the new computer, but which and why? And how to test it?

Anybody any bright ideas?

Arnoud Klaren
  • 93
  • 1
  • 9
  • I just built a small VB.NET application that uses the MySQL .NET connector and it worked fine on the new computer. So the problem could be in the MySQL ODBC connector and/or the Microsoft ActiveX Data Objects 6.1 library in combination with the new MySQL server??? – Arnoud Klaren Nov 10 '16 at 22:19
  • Sorry, I initially specified the wrong version number of the MySQL ODBC connector on the new computer. Corrected this from 5.3.4 to 5.3.6. – Arnoud Klaren Nov 15 '16 at 10:04

3 Answers3

3

To further locate the cause of the problem, I downgraded the MySQL ODBC driver 5.3.6 on the new computer to version 5.3.4 (which is on the old computer) and now it works! To confirm that this is indeed the cause, I upgraded to version 5.3.6 again and it failed again.

So it looks like MySQL ODBC driver 5.3.6 (released 8 months ago!) has problems handling output parameters from a (local) MySQL Server 5.7.16, maybe only in combination with ADODB and Windows 10.

So for the moment I will use the 5.3.4 version and report a bug to MySQL.

Arnoud Klaren
  • 93
  • 1
  • 9
  • 1
    Thanks for taking the time to post your findings and report the issue to MySQL. – Gord Thompson Nov 15 '16 at 12:46
  • Looks like someone else also encountered this problem 11 days ago. See https://bugs.mysql.com/83698. – Arnoud Klaren Nov 15 '16 at 13:38
  • @Gord Thanks, I have had a lot of help from other SO posts, so this is my contribution to the community. I'll keep you posted. – Arnoud Klaren Nov 15 '16 at 13:41
  • I went back to `Connector/ODBC 5.3.4` and I can confirm your solution works. I'm using `MySQL 5.7.16-log` and `Excel 2013` in a `Windows 7 SP1`. I'm sad to lose the whole day messing with my code, but I'm very glad to have found your solution (and to find out that my code has no problems). Thank you very much for you solution. You have great problem solving skills, I don't think I could've figured out this solution by myself. – feelthhis Jan 29 '18 at 22:10
1

MySQL server version 5.7 has compatibility issues with latest ODBC connectors. Downgrading the server to version 5.6 fixed the issue.

1

Even after 4 years, this bug is still there. Since I could not get any MySQL 5.3/8.0 ODBC driver to work with MySQL Server 8.0.22 and I did not want to be held hostage by this bug any longer, I decided to switch from a stored procedure (with an output parameter) to a stored function (with a return value) and made a few changes in the VBA example above:

.CommandType = adCmdText
.CommandText = "select testit() as parOut"
Set dbRest = .Execute
dbTestIt = dbRest!parOut
Arnoud Klaren
  • 93
  • 1
  • 9