COUNT = 0

时间:2015-12-16 10:27:19

标签: mysql asp-classic recordset

为什么在查询中COUNT = 0时记录集不为空?

mysql_query = _
        ("SELECT " &_
        "COUNT" &_
            "(am_table_logg_id) " &_
        "AS " &_
            "TotalRecords " &_
        "FROM " &_
            "am_table " &_
        "WHERE " &_
            "am_table_logg_id = '" & id & "' ")

我有另一个包含primary_key id的表

21

67

am_table只有该表中的id 21。但是在两种情况下,recordSet都返回-1,表示有记录。

   set recordSet = conn.execute(mysql_query)
   cnt = recordSet("TotalRecords")
   response.write("cnt " & cnt & "<br>")

此输出

1
0

表示表中有1个出现21,没有出现67

但是recordSet.RecordCount在两种情况下都返回-1

Response.Write(recordSet.RecordCount & "<br>")

输出

-1
-1

根据文档-1表示有记录集

在下一个循环之前,我关闭记录集

recordSet.Close
set recordSet = nothing

我不明白这个?这里缺少什么?我应该使用其他光标类型吗?

0 个答案:

没有答案
相关问题