通过 ODBC 连接到 MS SQL Server
我有一个 Qt 4 应用程序尝试使用 Qt ODBC 驱动程序连接到 MS SQL Server 2008 数据库。该应用程序在 Windows 中运行时运行良好;然而,应用程序的目标操作系统是在 GNU/Linux 中运行。当应用程序在 GNU/Linux 中运行时,我收到以下错误:
QSqlError(0, "QODBC3: Unable to connect", " [unixODBC][Driver Manager]Data source name not found, and no default driver specified")
是否需要在 SQL 服务器或应用程序端配置某些内容才能使连接正常工作?
I have a Qt 4 application that is trying to connect to an MS SQL Server 2008 database using the Qt ODBC driver. The application runs fine when it is running in Windows; however, the target OS for the application is to have it run in GNU/Linux. When the application runs in GNU/Linux I get the following error:
QSqlError(0, "QODBC3: Unable to connect", " [unixODBC][Driver Manager]Data source name not found, and no default driver specified")
Is there something I need to configure on the SQL server or application side to get the connection to work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我对 unixODBC 不太了解,但看看这里:
unixodbc.org/doc/
对于连接到 MSSQL,以下内容可能有用:
http://www.unixodbc.org/doc/FreeTDS.html
或.../FreeTDS2.html
I don't really know much about unixODBC, but have a look here:
unixodbc.org/doc/
For connecting to MSSQL, the following might be useful:
http://www.unixodbc.org/doc/FreeTDS.html
or .../FreeTDS2.html
尝试将
odbc.ini
文件复制到~/.odbc.ini
中。如果再次不起作用,请尝试将同一文件复制到/etc/odbc.ini
中。如果这不起作用,因为这些目录对于不同的 Unix 系统是不同的,请查找所有文件:*odbc*\.ini
并查看其中是否有一些为空。如果是这样,请将它们替换为正确的.ini
文件。我有同样的问题,这解决了它。但这是一个非常愚蠢的解决方案,所以我正在寻找更好的解决方案。希望有帮助(:
Try to copy the
odbc.ini
file in~/.odbc.ini
. If not working again, try to copy the same file into/etc/odbc.ini
. If this is not working, as these directories are different for different Unix systems, find all files:*odbc*\.ini
and see if some of them are empty. If so, replace them with the correct.ini
file.I had the same problem and this solved it. But it's a really stupid solution, so I'm looking for a better one. Hope that helped (: