注册 登录
编程论坛 ASP技术论坛

我要被玩死了rs.recordcount这个问题好大啊

ak47my 发布于 2008-10-10 12:55, 1881 次点击
rs.open "select * from sclass where username=" & names ,conn,1,1
      if rs.RecordCount <> 0 then
      Response.Write("通过")
          else
          Response.Write("无记录")
      end if    

有人说是因为rs.RecordCount=-1引起的
试了试把rs.open "" & names ,conn,1,1里的1,1 改成1,3 2,3 等都不行。
还有说是游标问题,也改过。。。还是存在问题

我用Response.Write 输出rs.RecordCount什么也没有

请问怎么回事啊。我新人。。谢谢

忘了说问题了
不管有没有记录,他都显示的是通过


[[it] 本帖最后由 ak47my 于 2008-10-10 12:57 编辑 [/it]]
9 回复
#2
tianyu1232008-10-10 13:29
这样判断试试
if not(rs.bof and rs.bof) then
   Response.Write("通过")
else
   Response.Write("无记录")
end
#3
yms1232008-10-10 15:13
同意2楼的做法用EOF比用RecordCount要好判断是否有数据。
#4
白居易2008-10-10 15:58
回复 1# ak47my 的帖子
2楼if not(rs.bof and rs.bof) then
是否应该改为if not(rs.eof and rs.bof) then
楼主将conn后面改为3,2试试

[[it] 本帖最后由 白居易 于 2008-10-10 16:17 编辑 [/it]]
#5
孤独冷雨2008-10-10 16:30
rs.open "select * from sclass where username=" & names ,conn,1,1
name是字符串吧?
rs.open "select * from sclass where username='&names&'" ,conn,1,1
#6
robinbest2008-10-10 17:24
应该是5楼所指的问题。关键不在判断上,而在那个查询语句上!
#7
wxm1984272008-10-11 10:08
我也觉得是那个查询语句的问题,楼主去试试看
#8
enlangs2008-10-11 11:37
支持2楼,一年都没来论坛了。。。

一年前“yms123”是版主,一年后还是。。“阳光白雪”呢?
#9
nicechlk2008-10-11 14:47
[bo][un]孤独冷雨[/un] 在 2008-10-10 16:30 的发言:[/bo]

rs.open "select * from sclass where username=" & names ,conn,1,1
name是字符串吧?
rs.open "select * from sclass where username='&names&'" ,conn,1,1

呵呵,username应该是字符串,这样写法肯定查询不到结果的!
#10
ak47my2008-10-11 23:23
谢谢各位,解决了
1