首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >FreeTDS错误:传入表数据流(TDS)远程过程调用(RPC)协议流不正确

FreeTDS错误:传入表数据流(TDS)远程过程调用(RPC)协议流不正确
EN

Stack Overflow用户
提问于 2012-12-03 12:39:28
回答 1查看 6.3K关注 0票数 4

我必须用ODBC从Arch Linux连接到MSSQL服务器。我使用FreeTDS,对于isql,它正在工作:

isql sqlexpress dev开发

但不是在PHP中。我在交互模式下使用PHP:

代码语言:javascript
代码运行次数:0
运行
复制
PHP > $conn = odbc_connect("sqlexpress", 'dev', 'Dev');
PHP > $a=odbc_exec($conn, 'SELECT * FROM measures;');
PHP Warning:  odbc_exec(): SQL error: [FreeTDS][SQL Server]The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 1 (""): Data type 0x00 is unknown., SQL state 37000 in SQLExecDirect in php shell code on line 1

Warning: odbc_exec(): SQL error: [FreeTDS][SQL Server]The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 1 (""): Data type 0x00 is unknown., SQL state 37000 in SQLExecDirect in php shell code on line 1

我已经搜索了很多,但我找不到任何解决办法(甚至连有同样问题的人都找不到)。我的配置文件:

/etc/odbc.ini:

代码语言:javascript
代码运行次数:0
运行
复制
[sqlexpress] 
Server = 192.168.10.39
Port = 1433
Driver = FreeTDS
Database = capture
UserName = dev
Password = Dev

/etc/odbcinst.ini:

代码语言:javascript
代码运行次数:0
运行
复制
[FreeTDS]
Description = FreeTDS driver
Driver = /usr/lib/libtdsodbc.so
Setup = /usr/lib/libtdsS.so
Trace = Yes
TraceFile = /tmp/freetds.log
FileUsage = 1
UsageCount = 1

祝您今天愉快!配对

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-12-03 14:28:34

下面是我从Ubuntu连接到MSSQL数据库的工作配置文件:

/etc/odbc.ini

代码语言:javascript
代码运行次数:0
运行
复制
# Define a connection to the MSSQL server.
# The Description can be whatever we want it to be.
# The Driver value must match what we have defined in /etc/odbcinst.ini
# The Database name must be the name of the database this connection will connect to.
# The ServerName is the name we defined in /etc/freetds/freetds.conf
# The TDS_Version should match what we defined in /etc/freetds/freetds.conf
[ebe]
Description             = MSSQL Server
Driver                  = freetds
Database                = my_database
ServerName              = my_server_name
TDS_Version             = 8.0

/etc/odbcinst.ini

代码语言:javascript
代码运行次数:0
运行
复制
# Define where to find the driver for the Free TDS connections.
[freetds]
Description     = MS SQL database access with Free TDS
Driver          = /usr/lib/i386-linux-gnu/odbc/libtdsodbc.so
Setup           = /usr/lib/i386-linux-gnu/odbc/libtdsS.so
UsageCount      = 1

# Change the "no" to "yes" to enable ODBC logging.
[ODBC]
Trace           = no
TraceFile       = /tmp/odbc.log

/etc/freetds/freetds.conf

代码语言:javascript
代码运行次数:0
运行
复制
[global]
        # If you get out-of-memory errors, it may mean that your client
        # is trying to allocate a huge buffer for a TEXT field.  
        # Try setting 'text size' to a more reasonable limit 
        text size = 64512

# Define a connection to the MSSQL server.
[my_server_name]
    host = my_server_domain_or_ip
    port = 1433
    tds version = 8.0

最后,这里是我的PHP连接字符串:

代码语言:javascript
代码运行次数:0
运行
复制
$this->db_connection = new PDO("dblib:dbname=my_database;host=my_server_domain_or_ip", 'username', 'password');

我相信将tds版本设置为8.0可能对你有很大帮助。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13683465

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档