一聚教程网:一个值得你收藏的教程网站

热门教程

select error:不能用DB-library(如isql)不能用DB-library(如isql)

时间:2022-06-29 08:11:20 编辑:袖梨 来源:一聚教程网

不能用DB-Library(如 ISQL)或 ODBC 3.7或更早版本将 ntext 数据

Warning: mssql_query() [function.mssql- query]: message: 不能用 DB-Library(如 ISQL)或 ODBC 3.7 或更早版本将 ntext 数据或仅使 用 Unicode 排序规则的 Unicode 数据发送到客户端。 (severity 16) in D:PHPnowhtdocss includedb_mssql.class.php on line 55

 代码如下 复制代码

Warning: mssql_query() [function.mssql-query]: Query failed in D:PHPnowhtdocssincludedb_mssql.class.php on line 55
MsSQL Query:SELECT * FROM PE_Config
MsSQL Error:1
MsSQL Errno:1
Message:MsSQL Query Error

在PB开发过程中,由于数据库中使用了 ntext字段,出现以下提示错误,郁闷了很长时间找不到解决方案,后查阅大量资料,终于明白:
PB报错: 不能用 DB-Library(如 ISQL)或 ODBC 3.7 或更早版本将 ntext 数据或仅使用 Unicode 排序规则的 Unicode 数据发送到客户端。

————————————————

由于sql server中,ntext和nvarchar字段是用unicode编码存储内容的,因此php通过mssql扩展读取带ntext和nvarchar类型字段的时候会抱错。

如果 title 字段类型为 nvarchar,content 字段类型为 ntext ,那么下面的sql语句会报错:

 代码如下 复制代码

select title,content from article where 1

正确的写法是:

 代码如下 复制代码

select convert(varchar(255),title) as title, convert(text,content) as content from article where 1

或者不使用ntext字段

不能用DB-Library(如 ISQL)或 ODBC 3.7或更早版本将 ntext 数据 Warning: mssql_query() [function.mssql- query]: message: 不能用 DB-Library(如 ISQL)或 ODBC 3.7 或更早版本将 ntext 数据或仅使 用 Unicode 排序规则的 Unicode 数据发送到客户端。 (severity 16) in D:PHPnowhtdocss includedb_mssql.class.php on line 55 Warning: mssql_query() [function.mssql-query]: Query failed in D:PHPnowhtdocssincludedb_mssql.class.php on line 55 MsSQL Query:SELECT * FROM PE_Config MsSQL Error:1 MsSQL Errno:1 Message:MsSQL Query Error 在PB开发过程中,由于数据库中使用了

热门栏目