I'm trying to port a website that uses a Microsoft Access database to MySQL. As a starting point, I'm trying to open the SQL database:
The (old) Access code was:
Set cn = Server.CreateObject ("ADODB.Connection")
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open "PathToThe/database.db"
The (new) MySQL code is:
Dim connection_string, cn
connection_string = "Driver={MySQL ODBC 5.1 Driver};" &_
"server=url;" &_
"port=3306;" &_
"option=131072;" &_
"stmt=;" &_
"database=databasename;" &_
"uid=username;" &_
"pwd=thepassword"
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open connection_string
When I use the above code, I get a "500 - Internal server error." If I comment out the "cn.Open connection_string" statement, I don't get the error (of course, the database isn't opened).
This is on a hosted Windows 2012 server.
I can connect to the SQL database using the MySQL Workbench program and the above url, database, username, and password, and I can see the tables and data. I can query the database using my hosts "Test MySQL" command with a simply "Select * from tablename"
I've check my connection string over and over. I've copied and pasted the url, password, etc from my source code into the Workbench to make sure I don't have a typo. I've tried without the "option=" setting (and setting it to 3). I've tried using a string literal rather than my connection_string variable. I am surprised that I get a 500 error rather than a database error.
Stumped.
UPDATE: It turned out that the hosting company didn't have the ODBC drivers installed.