8
I am trying to connect to a Mysql database via Excel VBA, but returns an error stating catastrophic failure. I made a test by putting the wrong password, or the name of the wrong database, and it informs that access has been denied or the database does not exist, so it seems that it is working, Mysql is responding, just can not make the connection.
I’m using:
- Mysql Server 4.1
- ODBC Nector 3.51
Note: I can’t touch the Mysql Server version for some questions. I thought about trying to upgrade the Nector to a version 5, but I was wondering if it would generate another problem with Mysqlserver.
Below the code I am using. I tried other variations, but it is always the same error. Do you have a solution to this problem?
Set Cn = New ADODB.Connection
With Cn
.ConnectionString = _
"driver={mysql odbc 3.51 driver};" & _
"server=localhost;database=oswau;" & _
"uid=root;pwd=;"
.CursorLocation = adUseClient
.Open
End With
Adding some more information: With the information passed by colleagues, updating the Nector to version 5 he communicated, but only with localhost. When I try to communicate with the Mysql server on the network, the error occurs indicating:"The ODBC driver does not support the requested properties. Below the code I am running to make the query. The error occurs when it tries to open the query in the rs.open part, last line of code below.
SQLStr = "Select Count(cd_tecnico) as 'Total' from Suporte_tecnico_nacional
where dt_suporte between '2014-06-01' and '2014-06-02' and cd_tecnico=23370"
Set Cn = CreateObject("ADODB.Connection") 'NEW STATEMENT
Cn.Open "Driver={MySQL ODBC 5.2 Unicode Driver};Server=" & _
Server_Name & ";Database=" & Database_Name & _
";Uid=" & User_ID & ";Pwd=" & Password & ";"
rs.Open SQLStr, Cn, adOpenStatic
There is a bug in this version of Connector. The problem is already old apparently, so install a new Connector can solve the problem. Confirm here whether your version of Mysql supports version 5.0 of Connector.
– Omni
And if I upgrade to a version 5, it will influence in some other connection with Mysqlserver or only in the connection made via VBA?
– user3771516
will affect all connections using the connector that are on the computer where the VBA is running.
– Omni
Ball show, updated the Nector to version 5.2, and now it worked. Thank you so much
– user3771516