首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

怎么根据表A的出货单号统计表B的总额

2013-09-12 
如何根据表A的出货单号统计表B的总额如图表A(出货单,或收款单)要统计每张出货单的总额表B (详细出货记录表

如何根据表A的出货单号统计表B的总额
如图
表A(出货单,或收款单)
要统计每张出货单的总额
怎么根据表A的出货单号统计表B的总额

表B (详细出货记录表,多行出货记录合并成一张出货单)

怎么根据表A的出货单号统计表B的总额

关键是 第10行 和146 行 的代码

第10行
rs2.Open "select SUM(zonger) as zonger2 from chuhuo where chuhuodan="&str,conn2,1,1

第146行

 <td height="22" align="left"><%=sumzonger(rs("chuhuodan"))%></td>

运行出错

错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E21)
ODBC 驱动程序不支持所需的属性。
/shoukuan/shoukuan.asp, 第 10 行


总代码如下:

<!--#include file="Conn2.asp"-->

<html>
<head>

<%

function   sumzonger(str)
set rs2=server.CreateObject("adodb.recordset")
rs2.Open "select SUM(zonger) as zonger2 from chuhuo where chuhuodan="&str,conn2,1,1
if not rs2.eof then
sumzonger=rs2("zonger2")
else
sumzonger=""

end if

rs2.Close
set rs2=nothing
end   function

function   getdanwei(str)
set rs2=server.CreateObject("adodb.recordset")
rs2.Open "select danwei from chanpin where _identify="&str,conn2,1,1
if not rs2.eof then
getdanwei=rs2("danwei")
else
getdanwei=""
end if

rs2.Close
set rs2=nothing
end   function

%>


<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="style.css" type=text/css rel=stylesheet>

<style type="text/css">
<!--
body {
background-color: #ced7f7;
}
.STYLE3 {font-size: 15px}
.STYLE5 {
font-size: 36px;
font-weight: bold;
}
-->
</style></head>


<div align="center"><span class="STYLE5">出货单</span>
  
</div>
<P>

<table width="562" border="1" align="center" cellpadding="0" cellspacing="0">
  <tr>
   
    <td width="100" height="22" align="center"><span class="STYLE3">出货日期</span></td>
    <td width="96" align="center">出货单</td>
    <td width="192" height="22" align="center">单位名称</td>


    <td width="91" height="22" align="center">金额</td>
    <td width="71" height="22" align="center">收款</td>
  </tr>
  
  <%


'开始分页
MaxPerPage=30
   dim totalPut   
   dim CurrentPage
   dim TotalPages
   dim j
   dim sql
    if Not isempty(request("page")) then
      currentPage=int(request("page"))
   else
      currentPage=1
   end if

set rs=server.CreateObject("adodb.recordset")
sql="select * from chuhuodan  where _identify>0 "
            
if kehuid<>"" then
 kehuid="kehuid"
 end if

            sql=sql&" order by _identify desc"
            rs.open sql,conn2,1,1


  if rs.eof And rs.bof then
       Response.Write "<p align='center' class='contents'> 对不起,没有找到相关信息!</p>"
   else
  totalPut=rs.recordcount

      if currentpage<1 then
          currentpage=1
      end if

      if (currentpage-1)*MaxPerPage>totalput then
   if (totalPut mod MaxPerPage)=0 then
     currentpage= totalPut \ MaxPerPage
   else
      currentpage= totalPut \ MaxPerPage + 1
   end if
      end if

       if currentPage=1 then
            showContent
            showpage totalput,MaxPerPage,"shoukuan.asp"
       else
          if (currentPage-1)*MaxPerPage<totalPut then


            rs.move  (currentPage-1)*MaxPerPage
            dim bookmark
            bookmark=rs.bookmark
            showContent
             showpage totalput,MaxPerPage,"shoukuan.asp"
        else
        currentPage=1
           showContent
           showpage totalput,MaxPerPage,"shoukuan.asp"
      end if
   end if
      end if

   sub showContent
       dim i

   i=0
do while not rs.eof


%>
  <tr>

    <td height="22" align="center"><span class="STYLE3"><%=rs("chuhuodate")%></span></td>
    <td align="left"><%=rs("chuhuodan")%></td>
    <td height="22" align="left"><%=rs("kehuname")%></td>
    <td height="22" align="left"><%=sumzonger(rs("chuhuodan"))%></td>
    <td height="22" align="center"><form name="form1" method="post" action="">
      <label>
        <input type="checkbox" name="checkbox" value="checkbox">
        </label>
    </form>
    </td>
  </tr>
  <%i=i+1
     
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
set rs=nothing%>
</table>


<% End Sub   
Function showpage(totalnumber,maxperpage,filename)  
  Dim n
  
If totalnumber Mod maxperpage=0 Then  
n= totalnumber \ maxperpage  
Else
n= totalnumber \ maxperpage+1  
End If



Response.Write "<form method=Post action="&filename&"?selectm="&selectm&"&selectkey="&selectkey&" >"  
Response.Write "<p align='center' class='contents'> "  
If CurrentPage<2 Then  
Response.Write "<font class='contents'>首页 上一页</font> "  
Else  
Response.Write "<a href="&filename&"?page=1&tel="&tel&" class='contents'>首页</a> "  
Response.Write "<a href="&filename&"?page="&CurrentPage-1&"&tel="&tel&" class='contents'>上一页</a> "  
End If

If n-currentpage<1 Then  
Response.Write "<font class='contents'>下一页 尾页</font>"  
Else  
Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&"&tel="&tel&" class='contents'>"  
Response.Write "下一页</a> <a href="&filename&"?page="&n&"&tel="&tel&" class='contents'>尾页</a>"  
End If  
Response.Write "<font class='contents'> 页次:</font><font class='contents'>"&CurrentPage&"</font><font class='contents'>/"&n&"页</font> "  
Response.Write "<font class='contents'> 共有"&totalnumber&"条记录 " 
Response.Write "<font class='contents'>转到:</font><input type='text' name='page' size=2 maxlength=10 class=smallInput value="&currentpage&">"  
Response.Write "&nbsp;<input type='submit'  class='button' value='GO' name='cndok'></form>"  
End Function  
%>


</html>


怎么实现呢?

[解决办法]
rs2.Open "select SUM(zonger) as zonger2 from chuhuo where chuhuodan='" & Replace(str, "'","''") & "'",conn2,1,1



热点排行