这段ASP代码为什么总不对?

来源:百度知道 编辑:UC知道 时间:2024/06/27 18:00:25
<%'计算取现总额
set rsch=server.createobject("adodb.recordset")
sqlch="select * from bank_cash"
rsch.open sqlch,conn,1,1
dim chamount
dim chtotal
chamount=0
chtotal=0
if not (rsch.bof and rsch.eof) then
do while not rsch.eof
chamount=rsch("amount")
chtotal=chtotal+chamount
rsch.movenext
loop
end if
rsch.close
set rsch=nothing%>
结果显示 chamount总是正确的,而chtotal总是0,真是太奇怪了,快要抓狂啦!请大虾帮忙

检查rsch("amount")所有的值。看看有没有意外,实在不行+38097630

<%'计算取现总额
set rsch=server.createobject("adodb.recordset")
sqlch="select * from bank_cash"
rsch.open sqlch,conn,1,1
dim chamount
dim chtotal
chamount=0
chtotal=0
if not (rsch.bof and rsch.eof) then
do while not rsch.eof
chamount=rsch("amount")
chtotal=chtotal+chamount
response.write("单笔:"&amount&" 累计:"&chtotal&"<br>") '每循环一次输出一次看看正不正确。
rsch.movenext
loop
end if
rsch.close
set rsch=nothing%>