“Data source name not found and no default driver

2019-07-26 03:41发布

问题:

Due to some technical reasons, I had to change my database from sql server to MySQL. But I am getting the following error, I cannot connect to the database..!

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Set ObjConn = CreateObject("ADODB.Connection")
ObjConn.Open ("DRIVER={MySQL ODBC 5.0.96 Driver};SERVER=68.128.172.38;DATABASE=xxx;UID=xxx;PWD=xxx")

回答1:

here you go with a sample connection string

Server_Name = "localhost" 'connect to the local  remort database server

databseName = "db" 'database name
mySQLUser = "root" 'user name
mysqlPassword = "admin" 'passwrd of the db user

ConStr= "Driver={MySQL ODBC 5.1 Driver};SERVER=" & Server_Name  & ";DATABASE=" & databseName & ";UID=" & mySQLUser & ";PWD=" & mysqlPassword & ";PORT=3306;OPTION=67108864;" ' Connection string

if that doesn't work, try installing the relevent connector for mysql Select and download the connector