【发布时间】:2021-05-10 18:43:10
【问题描述】:
我尝试在 C++ 中通过 Ado 连接到 MariaDB 数据库。
CADODatabase m_dbConnection;
(我的测试.h)
m_dbConnection.SetConnectionString(strConnectionString);
m_dbConnection.SetConnectionTimeout(60);
连接字符串是
DRIVER={MariaDB ODBC 3.1 Driver}; Server=xx.xx.xx.xx.xx; Port=3306; database=db; UID=8001; password=********;
我尝试设置 DSN,但我不知道连接字符串的外观如何?
DSN=Name;
程序是 32 位还是 64 位版本重要吗?在这种情况下使用哪个 DSN?
我总是得到错误:
Init(): Could not connect to database with connection string 'DSN=Cue1 DATABASE=yesdb'
Error message: Connection String = DSN=Cue1 DATABASE=yesdb
CADODataBase Error
Code = 80004005
Code meaning = Unspecified error
Source = Microsoft OLE DB Provider for ODBC Drivers
Description = [Microsoft][ODBC Driver Manager] Data source name not found and no default driver
specified
或
Init(): Could not connect to database with connection string 'Driver={MariaDB ODBC 3.1 Driver}
Server=xx.xx.xx.xx; Port=3306; database=db; UID=8001; password=xxxxxxx;Option=3;'
Error message: Connection String = Driver={MariaDB ODBC 3.1 Driver} Server=xx.xx.xx.xx; Port=3306;
database=db; UID=8001; password=xxxxxx;Option=3;
CADODataBase Error
Code = 80040e73
Code meaning = IDispatch error #3187
Source = Microsoft OLE DB Service Components
Description = Format of the initialization string does not conform to the OLE DB specification.`
有什么想法吗?
【问题讨论】: