注册 登录
编程论坛 ASP技术论坛

汇总结果取不到值,请指教,问题应该在末端代码中,但是我看不出来

eournet 发布于 2013-09-24 22:11, 1218 次点击
代码运行结果目标:写入数据库N条数据后汇总一次,结束
汇总结果取不到值,请指教,问题应该在末端代码中,但是我看不出来


<%
if request("hid1")="ok" then
nowselldate=request("selldate")
nowenddate=request("enddate")
nowbeizhu=request("beizhu")
nowprice=request("price")
nowbzr=request("bzr")
nowtype=request("type")
nowid_danwei=request("id_danwei")
nowid_produit=request("id_produit")
nowid_huiyuan=request("id_huiyuan")
nowid_login=request("id_login")
set rs_login=conn.execute("select * from login where id="&nowid_login)
nowid_ku=request("id_ku")
set rs_ku=conn.execute("select * from ku where id="&nowid_ku)
nowid_gys=request("id_gys")
nowgys=request("gys")
nowjxf=request("jxf")
nowybf=request("ybf")
nowgrxs=request("grxs")
nowfcf=request("fcf")
nowaqf=request("aqf")
nowgj=request("gj")
nowbianhao=replace(replace(replace(replace(replace(replace(FormatDateTime(now(),0),":","")," ",""),"-",""),"/",""),"上午",""),"下午","")
'totalshulian=0
for x=1 to maxproduit
nowhuohao=request("huohao"&x)
nowtitle=request("title"&x)
nowshulian=request("shulian"&x)
nowid_danwei=request("id_danwei"&x)
nowprice2=request("price2"&x)
nowprice1=request("price1"&x)
nowbigclass=request("bigclass"&x)
if nowprice2="" then
  nowprice2=0
end if
if nowprice1="" then
  nowprice1=0
end if
if nowshulian="" then
  nowshulian=0
end if
if nowhuohao<>"选择定额" and nowshulian<>"" then
set rs_dek=conn.execute("select * from dek where debh='"&nowhuohao&"'")
set rs=server.createobject("ADODB.RecordSet")
sql="select * from b3j where 1=2"
rs.open sql,conn,1,3
rs.addnew
rs("huohao")=nowhuohao
rs("title")=nowtitle
rs("shulian") =nowshulian
rs("id_danwei")=nowid_danwei
rs("price1")=nowprice1
rs("price2")=nowprice2
rs("bigclass")=nowbigclass
rs("id_gys")=nowid_gys
rs("id_produit")=nowid_produit
rs("id_huiyuan")=nowid_huiyuan
rs("price")=nowprice
rs("id_ku")=nowid_ku
rs("bzr")=nowbzr
rs("gys")=nowgys
rs("type")=nowtype
rs("selldate")=nowselldate
rs("enddate")=nowenddate
rs("id_login")=nowid_login
rs("login")=rs_login("username")
rs("bianhao")=nowbianhao
rs("beizhu")=nowbeizhu
rs("ybf")=nowybf
rs("jxf")=nowjxf
rs("grxs")=nowgrxs
rs("fcf")=nowfcf
rs("aqf")=nowaqf
rs("gj")=nowgj
rs("jggr")= nowprice1*nowshulian
rs("pggr")= nowprice2*nowshulian
rs.update
end if
next

set count_b3j = server.createobject("ADODB.RecordSet")   
count_b3j.open sql,conn,1,3
nowjggr=0
nowpggr=0
do while count_b3j.eof=false
  sql3="select sum(jggr),sum(pggr) from b3j where bianhao='"&nowbianhao&"' "
        set rs_sum=conn.execute(sql3)  
  nowjggr=nowjggr+rs_sum(0)
  nowpggr=nowpggr+rs_sum(1)
  count_b3j.movenext
loop
set rs2=server.createobject("ADODB.RecordSet")
sql="select * from b3j where bianhao='"&nowbianhao&"'"
rs2.open sql,conn,1,3
do while rs2.eof=false
rs2.addnew
rs2("bianhao")=nowbianhao
rs2("title")="---[工日小计]---"
rs2("jggr")=nowjggr    汇总结果取不到值
rs2("pggr")=nowpggr    汇总结果取不到值

rs2.movenext
loop

%>
15 回复
#2
eournet2013-09-25 20:20
快来帮我看看啊
#3
eournet2013-09-25 21:09
rs_sum(0)
rs_sum(1)好像都没有值,数据库写入数据是0,求高手来看下我代码错在哪了
#4
eournet2013-09-26 19:40
快来帮我看看啊
#5
eournet2013-09-27 13:31
怎么如此冷清
#6
eournet2013-09-28 16:10
版主来帮我看看啊
#7
eournet2013-09-30 08:18
高手来来去去,怎么不见回复,帮忙看下,我代码哪里有问题@谢谢
#8
eournet2013-10-06 00:35
为何我的问题无人回答
#9
hu9jj2013-10-06 21:54
也许是楼主的代码太长,有时间慢慢分析的人不多的缘故吧。
#10
hu9jj2013-10-06 21:55
另外一个可能就是长假期间很多人没有那么多时间上网。
#11
eournet2013-10-07 08:54
主要是这部分代码,现在关键的问题是nowjggr、nowpggr取不到值,帮我看下,我对字段求和不甚了解
set count_b3j = server.createobject("ADODB.RecordSet")   
count_b3j.open sql,conn,1,3
nowjggr=0
nowpggr=0
do while count_b3j.eof=false
  sql3="select sum(jggr),sum(pggr) from b3j where bianhao='"&nowbianhao&"' "
        set rs_sum=conn.execute(sql3)  
  nowjggr=nowjggr+rs_sum(0)
  nowpggr=nowpggr+rs_sum(1)
  count_b3j.movenext
loop
set rs2=server.createobject("ADODB.RecordSet")
sql="select * from b3j where bianhao='"&nowbianhao&"'"
rs2.open sql,conn,1,3
do while rs2.eof=false
rs2.addnew
rs2("bianhao")=nowbianhao
rs2("title")="---[工日小计]---"
rs2("jggr")=nowjggr    汇总结果取不到值
rs2("pggr")=nowpggr    汇总结果取不到值

rs2.movenext
loop

#12
ysf01812013-10-07 15:17
看代码的运算的,

ii = 0

ii = ii + 1
response.end
一步一步查
#13
eournet2013-10-07 20:18
没有任何结果显示,还是请版主帮我看看这个代码书写是否正确
#14
eournet2013-10-07 21:31
已解决。代码修改为:
sql="select * from  B3J where bianhao='"&nowbianhao&"' and zu=false"
      set rs_shulian=conn.execute(sql)
      nowjggr=0
      nowpggr=0
      do while rs_shulian.eof=false
        nowjggr=nowjggr+rs_shulian("jggr")
        nowpggr=nowpggr+rs_shulian("pggr")
        rs_shulian.movenext
      loop
set rs2=server.createobject("ADODB.RecordSet")
sql="select * from B3J where bianhao='"&nowbianhao&"'"
rs2.open sql,conn,1,3
do while rs2.eof=false
rs2.addnew
rs2("bianhao")=nowbianhao
rs2("title")="总计[工日小计+工日小计×工日系数"&nowgrxs&"]"
rs2("jggr")=nowjggr
rs2("pggr")=nowpggr
rs2("zu")=true
rs2.movenext
loop
#15
hu9jj2013-10-08 07:58
解决了就好,祝贺你。
#16
eournet2013-10-08 09:50
但是有一点我不明白,为什么用一开始的代码就取不到汇总值,其实后一种写法我也是猜测性尝试下的,没有想到有效果
1