I'm trying to connect to a Mysql database via Excel VBA, but it returns an error reporting catastrophic failure. I did a test by entering the wrong password, or the wrong database name, and it informs that access was denied or the database does not exist, so it seems to be working, Mysql is responding, it just can not make the connection.
I'm using:
- Mysql Server 4.1
- ODBC connector 3.51
Note: I can not play Mysql Server version for some issues. I thought about trying to upgrade the connector to a version 5, but I was wondering if it would not generate another problem with MysqlServer.
Below the code I'm using. I've tried other variations, but it's always the same mistake. 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 connector for 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, but the code I am executing to make the query. .open, 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