SQL Server 文本列影响返回到经典 ASP 的结果

SQL Server text column affects results returned to classic ASP(SQL Server 文本列影响返回到经典 ASP 的结果)

本文介绍了SQL Server 文本列影响返回到经典 ASP 的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用经典的 asp,我正在尝试像这样查询 SQL Server 数据库:

Using classic asp, I am trying to query a SQL Server database like so:

strSQL = "select column_1, column_2, column_3, column_4  from someview " &_
         "where RecordNo=" & i
set rs=conn.Execute(strSQL)

if not rs.eof then
    A = rs("column_1")
    B = rs("column_2")
    C = rs("column_3")
    D = rs("column_4")
end if

Column_3 为 NText 类型,其他列为 varchar 或 int(有时可能返回 4 列以上)但由于 where 子句,查询仅返回 1 条记录.

Column_3 is an NText type, the other columns are varchar or int (sometimes there may be more than 4 columns returned) but the query only returns 1 record because of the where clause.

在 ASP 页面上,结果各不相同 - 有时会填充 A、B、D,有时不会 - 但视图中的所有列都包含数据(当我查询 SQL Server 时,我看到了预期的结果 - 所有列都包含数据).如果我从 strSQL 中删除作为 NText 的 column_3 一切正常.

On the ASP page the results vary - sometimes A,B,D are populated, sometimes not - but all columns in the view contain data (when I query the SQL Server I see the expected results - all columns do contain data). If I remove column_3 which is NText from the strSQL everything works fine.

我过去曾在其他几个页面上看到过这种行为.如果我修改 ASP 以分别获取 column_3:

I've seen this behaviour on a couple other pages in the past. If I modify the ASP to get column_3 separately:

 strSQL = "select column_3 from someview where RecordNo=" & i

正确返回 NText 数据.

The NText data is returned correctly.

返回到经典 ASP 的 SQL Server 记录集是否有最大记录长度?除了将 NTEXT 拆分为单独的查询之外,我还能做些什么吗?

Is there a maximum record length to a SQL Server recordset returned to classic ASP? Apart from splitting out the NTEXT into a separate query, is there anything else I can do?

我突然想到尝试更改连接字符串 - 受此 评论类似问题 - 连接是通过 SQL Server ODBC 驱动程序 (Driver={SQL Server};).

It just occured to me to try changing the connection string - inspired by this comment on a similar problem - the connection is via SQL Server ODBC Driver (Driver={SQL Server};).

推荐答案

我遇到了这个问题.Microsoft 在其网站上的某处承认这一点.

I have had this problem. Microsoft acknowledge it somewhere on their website.

如果你把 NText 列 last 放在 SELECT 列表中,你就可以访问它了.但是,您的代码 读取 NText 值之后无法访问任何其他列.一旦你移动到记录集的下一行,你就可以了.

If you put the NText column last in the SELECT list, you will be able to access it ok. However, your code cannot access any other columns after it has read the NText value. Once you move to the next row of the recordset you're OK again.

最好的解决方案是更改您的连接字符串,并使用更现代的东西.这以最好的方式解决了问题!

Best solution is to change your connection string though, and use something more modern. That solves the problem in the best way!

这篇关于SQL Server 文本列影响返回到经典 ASP 的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:SQL Server 文本列影响返回到经典 ASP 的结果

基础教程推荐