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

刚学asp,遇到一个求和问题

发布于 2010-04-27 01:06, 449 次点击
我从数据库按要求搜索列出了各个费用,

怎么样把这些列出的费用,也自动求和,显示出来呢?

只有本站会员才能查看附件,请 登录


===========================================================以下是我的代码:

<table width="100%"  border="1" cellspacing="0" bordercolor="#000000">
  <tr bordercolor="#000000">
    <%
drss.movenext
III=III+1
loop
 end if
%>
    <td width="8%"><div align="center"><b><b> 类型</b></b></div></td>
    <td width="16%"><div align="center"><b>业务金额</b></div></td>
  </tr>
  <% If Request.QueryString("CurPage")="" or Request.QueryString("CurPage")=0 then
CurPage = 1
Else
CurPage = CINT(Request.QueryString("CurPage"))
End If

if lid<>"" then
souselect=souselect&" and y_lei="&lid&""
end if
if tt<>"" then
souselect=souselect&" and y_zhuangtai="&int(tt)&""
end if
if request("souname")<>"" then
souselect=souselect&"and (y_zhuti like '%"&request("souname")&"%' or y_user like '%"&request("souname")&"%' or y_bjie like '%"&request("souname")&"%'  or y_user_kehu like '%"&request("souname")&"%')"
end if
set drs= Server.CreateObject("adodb.recordset")
drs.open ("select * from nnt_yewu "&souselect&" "&selectquan&" order by y_stime desc "),conn,1,1

if drs.eof then
                  Response.Write("<tr><td colspan=6>该公司今日无任何已 完成 业务,请查询后再打印。</td></tr>")
                  else
                  
                  dRS.PageSize=20
    Dim TotalPages   
    TotalPages = dRS.PageCount   
   
    If CurPage>dRS.Pagecount Then     
        CurPage=dRS.Pagecount   
    end if
   
    dRS.AbsolutePage=CurPage   
   
    drs.CacheSize = dRS.PageSize   
     
    Dim y_bjie
    y_bjie=split(drs("y_bjie"),"|@|")
   
   
    Dim Totalcount   
    Totalcount =INT(dRS.recordcount)
    do while (Not dRS.Eof) and (II<dRS.PageSize)
    y_user_kehu=split(drs("y_user_kehu"),"||")
 %>
  <script language="JavaScript">
window.onload=function(){
obj=document.all.tags('INPUT');
for(i=0;i<obj.length;i++)
obj[i].value=(obj[i].parentElement.parentElement.sectionRowIndex-1);
}
</script>
  <tr bordercolor="#000000"  onmouseover="javascript:bgColor='#C8E4FF'" onmouseout="javascript:bgColor='#ffffff'">
    <td><div align="center"><%= yewulei_fen(drs("y_lei")) %></div></td>
    <td align="center"><% if drs("y_money")>0 then %>
        <font color="#FF3300"><%= FormatCurrency(drs("y_money")) %> </font>
        <% ElseIF drs("y_money")<0 then%>
        <font color="#006600"><%= FormatCurrency(drs("y_money")) %> </font>
        <% end if %></td>
  </tr>
  <tr>
    <td><div align="center" style="font-family: &quot;黑体&quot;; font-size: 14px; font-weight: bold">总金额</div></td>
    <td bordercolor="#000000"><div align="center">1</div></td>
  </tr>
</table>


[ 本帖最后由 xiongranxi 于 2010-4-27 15:42 编辑 ]
6 回复
#2
2010-04-27 09:47
大家帮帮我啊。。。
#3
yms1232010-04-27 12:00
那些数据要求和?
#4
2010-04-27 13:20
以下是引用yms123在2010-4-27 12:00:52的发言:

那些数据要求和?
业务金额
#5
2010-04-27 15:36
期待高手指点一下啊。。
#6
hams2010-04-27 16:15
做个累计不就行了
#7
2010-04-27 17:50
自己解决了。。

代码如下:

<%
set raas= Server.CreateObject("adodb.recordset")
raas.open ("Select Sum(y_money) as SumNum from nnt_yewu "&souselect&" "&selectquan&" "),conn,1,1
Response.Write "¥ "&raas("SumNum")
%>
1