无法使用 soci 库连接到 SQL 服务器
Unable to connet to SQL server using soci library
我是 c++ 的初学者,我在 Linux 上使用 soci 库连接到 SQL Server 的问题,我的代码这个,但我有错误,我没有找到我的问题的解决方案,我的代码是这样的:
我有错误:
[unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL state IM002)
这是代码:
try{
soci::session sql("odbc","DSN=ODBC;UID=sa;PWD=sa123; Connection Driver=TDS;Database=ReportServer; Server=192.168.1.52;Port=1433;");
}
catch(soci::odbc_soci_error const & e){
cout<<"start error";
cout<<e.odbc_error_code()<<endl;
cout<<e.what();
}
ODBC 连接字符串不正确,第一个参数指定名为"ODBC"的数据源,该数据源尚未在操作系统/ODBC 管理器中配置。
因此,您应该使用给定的参数(如UID=sa;PWD=sa123; Connection Driver=TDS;Database=ReportServer; Server=192.168.1.52;Port=1433;
相应的 ODBC 数据源管理器/linux 管理程序)配置数据源,使用可用名称(如"local_test_db"),并且仅使用"DSN=local_test_db"作为连接字符串
(独占或)
从连接字符串中删除"dsn=ODBC"部分,然后使用"UID=sa;PWD=sa123;连接驱动程序 = TDS;数据库 = 报表服务器;服务器=192.168.1.52;端口=1433;"
相关文章:
- C++ Qt SQL lite 数据库连接问题
- 如何在C++代码中连接 SQL Server 数据库
- SQL Server 2017 C++ ODBC 连接在 Linux 上不起作用
- QT 5.8 SQL连接错误:Windows 10上未加载QMYSQL驱动程序
- 来自 Visual C++ Windows Form 项目的 SQL 连接
- C++ SQL 连接"get_driver_instance(); is undefined "错误
- 以编程方式连接到远程 SQL Server C++
- 如何与SQL Server 2008建立稳定的连接,并在C 中编码我的第一个CRUD操作
- 通过c++xll进行sql连接
- Sql Express SQL 驱动程序连接C++
- 使用 SQL Server 和 Oracle 中的字符串使用相同的未修改查询进行连接
- C++MySQL连接器无法在sql::Connection close()调用上断开TCP连接
- 如何用c++在sql连接中插入数组元素
- 非常长的查询执行使用c++, Sql Server和ODBC连接
- 使用Visual Studio Express 2013在c++中解决SQL Server连接问题
- 如何从Linux上的c++连接并执行一个简单的查询到SQL Server
- 在c++ (WIN32)中测试SQL连接字符串
- c++安全SQL连接
- C++SQL Server连接,然后以特定方式读取表
- Qt连接Sql Server(通用连接字符串)