Trying to connect to MySQL from Excel VBA
I am trying unsuccessfully to connect to the sample database sakila in my new MySQL installation from Excel VBA with the following code:
Sub ConnectToMySQL()
Dim sakilaConn As ADODB.Connection
Set sakilaConn = New ADODB.Connection
sakilaConn.ConnectionString = "DRIVER={MySQL ODBC 5.3 ANSI Driver};" & _
"SERVER=localhost;" & _
"DATABASE=sakila;" & _
"UID=myUserID;" & _
"PWD=myPassword" & _
"OPTION=3"
sakilaConn.Open
sakilaConn.Close
It fails at the Open with:
Run-time error '-2147467259 (80004005)':
[Microsoft][ODCB Driver Manager] Data source name not found and no default driver specified
Note: MySQL for Excel is installed and connecting through it succeeds, no problem.
Running:
Windows 10 64-bit
Excel 2013 32-bit
MySQL 5.7.9 (64-bit?)
Probably shouldn't be a factor, but myPassword does contain special chars.
Thanks for any advice you can provide.
Subject
Views
Written By
Posted
Trying to connect to MySQL from Excel VBA
15655
October 28, 2015 11:24AM
4697
October 28, 2015 12:22PM
3279
October 28, 2015 12:59PM
3657
October 29, 2015 12:28PM
3002
October 29, 2015 01:59PM
3506
November 04, 2015 10:33AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.