[求助]这些代码能用一段代码来写吗?
<%
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.MapPath("data/data.mdb")
'7月份
exec="select bb as mq,sum(myqty) as ql,month(mydate) as rl from zmp where month(mydate)=7 group by bb,month(mydate)"
set rs=server.CreateObject("adodb.recordset")
rs.open exec,conn,1,3
do while not rs.eof
stsql="update kc set 7月='"&rs("ql") & "' where kc.bb='"&rs("mq") & "'"
conn.execute stsql
rs.movenext
loop
'8月份
exec="select bb as mq,sum(myqty) as ql,month(mydate) as rl from zmp where month(mydate)=8 group by bb,month(mydate)"
set rs=server.CreateObject("adodb.recordset")
rs.open exec,conn,1,3
do while not rs.eof
stsql="update kc set 8月='"&rs("ql") & "' where kc.bb='"&rs("mq") & "'"
conn.execute stsql
rs.movenext
loop
'9月份
exec="select bb as mq,sum(myqty) as ql,month(mydate) as rl from zmp where month(mydate)=9 group by bb,month(mydate)"
set rs=server.CreateObject("adodb.recordset")
rs.open exec,conn,1,3
do while not rs.eof
stsql="update kc set 9月='"&rs("ql") & "' where kc.bb='"&rs("mq") & "'"
conn.execute stsql
rs.movenext
loop
'10月份
exec="select bb as mq,sum(myqty) as ql,month(mydate) as rl from zmp where month(mydate)=10 group by bb,month(mydate)"
set rs=server.CreateObject("adodb.recordset")
rs.open exec,conn,1,3
do while not rs.eof
stsql="update kc set 10月='"&rs("ql") & "' where kc.bb='"&rs("mq") & "'"
conn.execute stsql
rs.movenext
loop
conn.close
set conn=nothing
%>
这些代码能用一段代码来写吗?
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.MapPath("data/data.mdb")
'7月份
exec="select bb as mq,sum(myqty) as ql,month(mydate) as rl from zmp where month(mydate)=7 group by bb,month(mydate)"
set rs=server.CreateObject("adodb.recordset")
rs.open exec,conn,1,3
do while not rs.eof
stsql="update kc set 7月='"&rs("ql") & "' where kc.bb='"&rs("mq") & "'"
conn.execute stsql
rs.movenext
loop
'8月份
exec="select bb as mq,sum(myqty) as ql,month(mydate) as rl from zmp where month(mydate)=8 group by bb,month(mydate)"
set rs=server.CreateObject("adodb.recordset")
rs.open exec,conn,1,3
do while not rs.eof
stsql="update kc set 8月='"&rs("ql") & "' where kc.bb='"&rs("mq") & "'"
conn.execute stsql
rs.movenext
loop
'9月份
exec="select bb as mq,sum(myqty) as ql,month(mydate) as rl from zmp where month(mydate)=9 group by bb,month(mydate)"
set rs=server.CreateObject("adodb.recordset")
rs.open exec,conn,1,3
do while not rs.eof
stsql="update kc set 9月='"&rs("ql") & "' where kc.bb='"&rs("mq") & "'"
conn.execute stsql
rs.movenext
loop
'10月份
exec="select bb as mq,sum(myqty) as ql,month(mydate) as rl from zmp where month(mydate)=10 group by bb,month(mydate)"
set rs=server.CreateObject("adodb.recordset")
rs.open exec,conn,1,3
do while not rs.eof
stsql="update kc set 10月='"&rs("ql") & "' where kc.bb='"&rs("mq") & "'"
conn.execute stsql
rs.movenext
loop
conn.close
set conn=nothing
%>