查询仅返回表中12个值中的4个。为什么会这样?

问题描述 投票:0回答:1

我创建了一个脚本,正在2个不同的系统上使用。一种是带有SQL Server Express 2019的Windows 10,另一种是带有SQL Server Express 2014的Windows 7(32位)。我正在使用的数据库具有相同的结构。我在ASP Classic中使用的代码在两台机器上完全相同!但是在win7机器上不能正常工作!

我正在查询数据库,问题是我得到的某些值是空的!我正在使用的代码如下:

        <%
 Set rs21 = Server.CreateObject("ADODB.Recordset")
 strSQL21 = "SELECT * FROM otherfiles WHERE animalid LIKE '" & lngRecordNo & "'
 AND historyid LIKE '" & historyid & "' order by datedone DESC"

 rs21.Open strSQL21, adoCon
 %>
 BLAH BLAH BLAH
 <%
Do While not rs21.EOF
historyid = rs21("historyid")

if not historyid = "" then
Set rshis = Server.CreateObject("ADODB.Recordset")
strSQLhis = "SELECT * FROM history WHERE id_no LIKE '" & historyid & "' order by id_no DESC"
rshis.Open strSQLhis, adoCon

 '------------------- if I remove the following line (Set rscol) it works fine ---------------------------
Set rscol = Server.CreateObject("ADODB.Recordset")
strcol = "SELECT * FROM hospitals WHERE id_no = "& rsGuestbook21("hosid") &" order by id_no DESC"
rscol.Open strcol, adocon
color = rscol("color")
%>

     BLAH BLAH BLAH

    <%=rs21("datedone")%> ---> empty value
    <%=rs21("id_no")%> ---> works fine!!!

我100%确信我的表有其值。实际上,正如我上面提到的,但设置rscol = Server.CreateObject(“ ADODB.Recordset”)时,这些值将变为“空”。评论这行工作正常。您能帮我吗?

谢谢你!!

performance asp-classic is-empty
1个回答
0
投票

我刚发现我的错误?...

不确定是否是您的错...但是当我在表的末尾放置一个数据类型为“ nvarchar(MAX)”的字段时,问题解决了!奇怪的东西???您是否认为我应该调查的内容还不止这些?

© www.soinside.com 2019 - 2024. All rights reserved.