【问题标题】:ADO Connection to MariaDBADO 连接到 MariaDB
【发布时间】: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.`

有什么想法吗?

【问题讨论】:

    标签: c++ database mariadb ado


    【解决方案1】:

    不确定您使用什么库来连接。

    CADODatabase m_dbConnection;
    

    我不习惯看到 CADODatabase。您的连接字符串看起来就像我使用 MySQL ADODB 库所期望的那样。但通常原始 ADO 连接字符串使用一个名为“Provider”的属性...

    【讨论】:

    • 不知道为什么没有解释就投反对票...这里有一些额外的文档来支持 OLE DB 连接字符串结构...特定于 Microsoft,因为 ADO 是/曾经是 Microsoft 构造..docs.microsoft.com/en-us/openspecs/sql_server_protocols/…
    • 嘿,很抱歉,Downvote 不是来自我!谢谢,我会尝试再看看。还有其他建议吗?我需要一些东西来调用存储过程!
    • 再次,不确定您使用的是什么库...在我用 C++ 编写的应用程序连接到 mariadb 但是,我一直使用他们的直接连接器来连接 C/C++。它实际上是用于 C 的……所以使用起来不是最有趣的……但也不算太糟糕。你可以在这里获取/阅读更多信息:mariadb.com/kb/en/mariadb-connector-c
    猜你喜欢
    • 1970-01-01
    • 2015-10-13
    • 2011-07-25
    • 1970-01-01
    • 2011-08-23
    • 1970-01-01
    • 2021-10-24
    • 1970-01-01
    相关资源
    最近更新 更多