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的時候,這是怎麼回事?
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