大家帮我看看这个IF语句怎么写

skyfish007 2005-11-15 07:39:49
exec="select * from book where qingkuang='xxx'"
rs.open exec,conn,1,1

do while not rs.eof

jilu=rs("code")
set rs2=server.createobject("adodb.recordset")
sql="select top 1 * from record where code='"&jilu&"' order by id desc"
rs2.open sql,conn,1,1

if rs2.bof and rs2.eof then \\如果为空
什么都不做,转到第4行do while 那里继续执行
end if

rs.movenext
loop
...全文
115 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
skyfish007 2005-11-15
  • 打赏
  • 举报
回复
哦,我懂了,程序也可以运行了~~~
谢谢楼上的,也谢谢大家,
其实是我一直弄不清楚~~唉,太笨了,555555
xxuu503 2005-11-15
  • 打赏
  • 举报
回复
if rs2.bof and rs2.eof then \\如果为空

else

response.write"<td>" & rs2(0) & "</td>" '\\如此下去!rs2(1),rs2(2)......

end if
skyfish007 2005-11-15
  • 打赏
  • 举报
回复
其实On Error Resume Next就可以继续执行
不过下面程序用到RS2记录的时候就会有一大片的空白,
非常影响美观呀~~~
skyfish007 2005-11-15
  • 打赏
  • 举报
回复
hehe

response.write"<td>" & rs2(0) & "</td>"

如此下去!


如果是这样,用到了RS2,但是RS2为空的话,它就报错
xxuu503 2005-11-15
  • 打赏
  • 举报
回复
hehe

response.write"<td>" & rs2(0) & "</td>"

如此下去!
skyfish007 2005-11-15
  • 打赏
  • 举报
回复
if rs2.bof and rs2.eof then \\如果为空

else

response.write "your data" '\\是不是像这样干?

end if

嗯,基本上是这个样,不过不是用response.write
而是用表格输出
skyfish007 2005-11-15
  • 打赏
  • 举报
回复
szjhxu(天野) ( ) 信誉:98 的方法也不行也~~~
if not (rs2.bof and rs2.eof) then \\如果为空
rs.movenext
end if

RS虽然移动了,可是RS2为空
下面用到RS2的时候就出错了
xxuu503 2005-11-15
  • 打赏
  • 举报
回复
if rs2.bof and rs2.eof then \\如果为空

else

response.write "your data" '\\是不是像这样干?

end if
skyfish007 2005-11-15
  • 打赏
  • 举报
回复
如果列出的第一个RS记录,在RS2里没有,就出错,
根本执行不下去

skyfish007 2005-11-15
  • 打赏
  • 举报
回复
这样说吧,
首先找到RS的记录集,肯定是有记录的,然后在RS记录集为条件搜索RS2的记录集,
如果RS有记录,而RS2无记录,跳过,什么都不执行,回到DO WHILE
如果RS有记录,RS2也有记录就列出来,
直到RS的末尾推出循环
king_shadow 2005-11-15
  • 打赏
  • 举报
回复
to szjhxu(天野):

if rs2.bof and rs2.eof then \\如果为空

end if

rs.movenext //他的rs.movenext是在下面,呵呵,所以说为空也行,不是吗?
text44 2005-11-15
  • 打赏
  • 举报
回复
不懂 关注一下
szjhxu 2005-11-15
  • 打赏
  • 举报
回复
To king_shadow(天才混混) :

楼主的意思好象是如果那两个为空的话,就不执行rs.movenext
king_shadow 2005-11-15
  • 打赏
  • 举报
回复
我楼上的也行~
king_shadow 2005-11-15
  • 打赏
  • 举报
回复
if rs2.bof and rs2.eof then \\如果为空
end if


其实你这边为空,不写,他就是直接再执行了。。。
szjhxu 2005-11-15
  • 打赏
  • 举报
回复
exec="select * from book where qingkuang='xxx'"
rs.open exec,conn,1,1

do while not rs.eof

jilu=rs("code")
set rs2=server.createobject("adodb.recordset")
sql="select top 1 * from record where code='"&jilu&"' order by id desc"
rs2.open sql,conn,1,1

if not (rs2.bof and rs2.eof) then \\如果为空
rs.movenext
end if

loop
skyfish007 2005-11-15
  • 打赏
  • 举报
回复
楼上的
不行哦
类型不匹配: 'continue' 哦

继续等
king_shadow 2005-11-15
  • 打赏
  • 举报
回复
if rs2.bof and rs2.eof then \\如果为空
continue //退出此次循环,,继续执行下一次循环
end if

试下~

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧