do while 循环

zhouqing2542 2009-03-30 10:35:35
set rz=server.CreateObject("adodb.recordset")
rz.open "select * from AccountInfo where deprno='251' ",conn,1,1
if not rz.eof then
num1=rz("num")

do while not rz.eof
SET RSs1=SERVER.CreateObject("ADODB.recordset")
rss1.open "select top 1 * from TradeList where ACCOUNTNO='"&num1&"' and DATEDIFF(MONTH, REFERDATE, getdate()) = 1 and tradetype='132' order by leftsum Asc",conn,1,1

IF Rss1.EOF THEN
ycye=ycye
else
ycye= rss1("leftsum")+ycye '卡内初额
end if
rss1.movenext
loop
rss1.close

end if
rz.close


根据deprno='251' 传得的值 然后查AccountInfo里 等于 deprno 的 num 字段 调出来之后传到下边的循环中 大家帮看一下这个循环没问题吧..是否能全部的累加到一个 就是 读出所有等于num值 的leftsum 字段.然后leftsum 加一起 还有一个问题就是输出时 提示 rss1.movenext BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录
...全文
110 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
never exists 2009-03-30
  • 打赏
  • 举报
回复
do while not (rz.eof and rz.bof) 去掉 bof好了
  • 打赏
  • 举报
回复
select  sum(leftsum) as ycye from TradeList where ACCOUNTNO in (select num from AccountInfo where deprno='251' ) and  DATEDIFF(MONTH, REFERDATE, getdate()) = 1    and tradetype='132' order by leftsum Asc



直接SQL语句不行??
sy_binbin 2009-03-30
  • 打赏
  • 举报
回复

[Quote=引用 5 楼 chinmo 的回复:]
我怎么有一种多此一举的感觉?

这个更新完全可以使用联查更新
没必要用do while吧
[/Quote]
  • 打赏
  • 举报
回复
我怎么有一种多此一举的感觉?

这个更新完全可以使用联查更新
没必要用do while吧
sy_binbin 2009-03-30
  • 打赏
  • 举报
回复
set rz=server.CreateObject("adodb.recordset")
rz.open "select * from AccountInfo where deprno='251' ",conn,1,1
if not (rz.bof and rz.eof) then
num1=rz("num")

do while not rz.eof
SET RSs1=SERVER.CreateObject("ADODB.recordset")
rss1.open "select top 1 * from TradeList where ACCOUNTNO='"&num1&"' and DATEDIFF(MONTH, REFERDATE, getdate()) = 1 and tradetype='132' order by leftsum Asc",conn,1,1

if not (rss1.eof and rss1.bof) then
ycye= rss1("leftsum")+ycye '卡内初额
else
ycye=ycye
end if
rss1.close

rz.movenext
loop
end if
rz.close
zhouqing2542 2009-03-30
  • 打赏
  • 举报
回复
set rz=server.CreateObject("adodb.recordset")
rz.open "select * from AccountInfo where deprno='251' ",conn,1,1
if not rz.eof then
num1=rz("num")

do while not (rz.eof and rz.bof)
SET RSs1=SERVER.CreateObject("ADODB.recordset")
rss1.open "select top 1 * from TradeList where ACCOUNTNO='"&num1&"' and DATEDIFF(MONTH, REFERDATE, getdate()) = 1 and tradetype='132' order by leftsum Asc",conn,1,1

if not (rss1.eof and rss1.bof) then
ycye= rss1("leftsum")+ycye '卡内初额
else
ycye=ycye
end if
rss1.close

rz.movenext
loop
end if
rz.close

改成这样子了.但提示 rz.movenext 错误 BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录
zhouqing2542 2009-03-30
  • 打赏
  • 举报
回复
貌似影响不大.大家在帮忙看看了.
redcn2004 2009-03-30
  • 打赏
  • 举报
回复
IF Rss1.EOF THEN
ycye=ycye
else
ycye= rss1("leftsum")+ycye '卡内初额
end if

改成这样:

if not (rss1.eof and rss1.bof) then
ycye= rss1("leftsum")+ycye '卡内初额
else
ycye=ycye
end if

28,391

社区成员

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

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