梦仍是一样谭咏麟:if rs.recordcount<>"0" then 怎么解释呢

来源:百度文库 编辑:中科新闻网 时间:2024/05/14 07:30:11
请大家帮忙看一下,这段代码什么意思呢,起什么作用?

<input type="Hidden" name="fkong" value='<%if rs.recordcount<>"0" then response.write "fkong" end if %>'>

<input type="Hidden" name="id" value='<% if rs.recordcount<>"0" then response.write rs("shjiaid") end if %>'>
.

是执行哪个呢?
这个什么意思:response.write rs("shjiaid") end if %>'>

.

if rs.recordcount<>0 then....
表示如果查询数据库匹配记录不为空,则....
recordcount代表查询出来的记录集个数
在判定条件中确实不能加引号,引号里面代表时字符串而不是数据,所以if rs.recordcount<>“0” then....
则代表记录集数不等于0这个字符,可对于rs.recordcount它只能是数字,这么写条件永远不成立。

response.write rs("shjiaid")
表示将当前记录集字段为shjiaid数据在当前页面显示。

rs.recordcount 表示记录集的总数

rs.recordcount<>"0" 表示如果记录集不是空的,就执行下面。。。。

不过上面写的似乎有问题,0不需要加""号的。