mbyan 2014-12-08 06:02 采纳率: 100%
浏览 1775
已采纳

asp 初学者 if语句不执行

exec="select bl,ed from yonghu where users = '"&ur&"'"
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,3,3
set zj=conn.Execute("select sum(je) as num from xinxi where users='"&ur&"'") 
set bgje=conn.execute("select sum(je) as num from xinxi where users='"&ur&"' and yt like '办公%'")
response.Write(not (bgje.bof and bgje.eof))
response.Write(bgje("num"))
if not(bgje.bof and bgje.eof) then
rs("bl")=0
rs("ed")=zj("num")/2
else
rs("bl")=bgje("num")/zj("num")*100
rs("ed")=zj("num")/2-bgje("num")
end if
rs.update
rs.close

其中not(bgje.bof and bgje.eof)输出的值始终是ture没有false的时候,这是怎么回事?

  • 写回答

2条回答 默认 最新

  • Go 旅城通票 2014-12-08 06:17
    关注

    sum,count这种sql语句总会有记录返回的,不需要判断游标是否在开始或者结束位置,你要判断rs这个游标,要不没有记录就会出错了

     exec="select bl,ed from yonghu where users = '"&ur&"'"
    set rs=server.createobject("adodb.recordset")
    rs.open exec,conn,3,3
    set zj=conn.Execute("select sum(je) as num from xinxi where users='"&ur&"'") 
    set bgje=conn.execute("select sum(je) as num from xinxi where users='"&ur&"' and yt like '办公%'")
    if rs.eof then'''''''''''''
      if not(bgje.bof or bgje.eof) then
        rs("bl")=0
        rs("ed")=zj("num")/2
      else
        rs("bl")=bgje("num")/zj("num")*100
        rs("ed")=zj("num")/2-bgje("num")
      end if
      rs.update
    else
      response.Write "记录不存在"
    end if
    rs.close
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 我这模型写的不对吗?为什么lingo解出来的下面影子价格这一溜少一个变量
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波