MySQL Forums
Forum List  »  MySQL for Excel

Trying to connect to MySQL from Excel VBA
Posted by: Jeff Wiseman
Date: October 28, 2015 11:24AM

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.

Options: ReplyQuote


Subject
Views
Written By
Posted
Trying to connect to MySQL from Excel VBA
15900
October 28, 2015 11:24AM


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.