连接mssql报错, 通过odbc

蜡笔小新啦 2012-10-29 03:51:43
我连接mssql 通过odbc,在linux redhat 64bit。
----> below is odbc and freetds configuration files.
------- freetds.conf--------------
[FreeTDS]
host=172.21.32.20
port=1433
tds version=7.2
client charset = GB2312
------------ odbcinst.ini-----------------
[TDS]
Description = TDS
Driver = /usr/local/lib/libtdsodbc.so
Trace = Yes
TraceFile=/tmp/odbcinst.log
UsageCount = 1
------------- odbc.ini -----------------
[SQLSERVER]
Driver = TDS
Description = sql server dsn
Trace = NO
Server = 172.21.32.20
Database = Live
Port = 1433
TDS_Version = 7.2
TraceFile=/tmp/sqlserver.log

----------------------- snippets ---------------------------
QString f3ErpDsn = QString::fromLocal8Bit("Driver={SQLSERVER};server=172.21.32.20;database=Live;uid=inp;pwd=inp;");
QSqlDatabase f3ErpDb= QSqlDatabase::addDatabase("QODBC");
f3ErpDb.setDatabaseName(f3ErpDsn);
// f3ErpDb.setDatabaseName("SQLSERVER");
f3ErpDb.setUserName("inp");
f3ErpDb.setPassword("inp");
QString sqlCmdStr = "select * from dbo.Table_Drilling_Data01 where status=1";
if ( ! f3ErpDb.open() )
{
qDebug() << f3ErpDb.lastError().text();
return 1;
}
QSqlTableModel model;
model.setTable("dbo.Table_Drilling_Data01");
model.setFilter("status=3");
model.select();
qDebug() << model.lastError().text();

----------------- error messages
1. "f3ErpDb.setDatabaseName(f3ErpDsn);"
当我设置setDatabaseName 为 f3ErpDsn.
错误信息是 : "QODBC3: Unable to connect", "[unixODBC][Driver Manager]Data source name not found, and no default driver specified")
我已经定义SQLSERVER在odbc.ini中,为什么他还是报错呢?

2. 如果我改成 "f3ErpDb.setDatabaseName("SQLSERVER");"
error message is : "[FreeTDS][SQL Server]The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 1 (""): Data type 0x00 is unknown. QODBC3: Unable to execute statement"
这又是为什么呢?


thanks
ken
...全文
112 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
蜡笔小新啦 2013-03-14
  • 打赏
  • 举报
回复
人呢?人都哪里去了?
蜡笔小新啦 2012-11-30
  • 打赏
  • 举报
回复
没人知道吗?

16,216

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧