标题:请高手帮助注释一段asp代码,有点难呀
取消只看楼主
hp3325
Rank: 2
等 级:论坛游民
帖 子:29
专家分:26
注 册:2009-6-7
结帖率:33.33%
 问题点数:0 回复次数:2 
请高手帮助注释一段asp代码,有点难呀
Function getCumulativeSalesByCatXML(intYear,forDataURL)
    Dim oRsCat, oRs, strSQL
    Dim strXML   
    Dim strCat, catXMLDone
    catXMLDone = false
    Dim strDataXML
    strDataXML = ""
    strCat = "<categories>"
    strSQL = "Select categoryId,categoryName from FC_Categories GROUP BY categoryId,categoryName"   
    Set oRsCat = Server.CreateObject("ADODB.Recordset")
    oRsCat.Open strSQL, oConn
    Dim strLink
    While not oRsCat.EOF
        strDataXML = strDataXML & "<dataset seriesName='" & escapeXML(oRsCat("categoryName"),forDataURL) & "'>"
        strSQL = "SELECT  Month(o.orderdate) as MonthNum, g.CategoryID, g.CategoryName, round(sum(d.quantity),0) as quantity, SUM(d.quantity*p.Unitprice) As Total FROM FC_categories as g,  FC_products as p, FC_orders as o, FC_OrderDetails as d  WHERE year(o.OrderDate)=" & intYear &" and g.categoryId=" & oRsCat("CategoryId") & " and d.productid= p.productid and g.categoryid= p.categoryid and o.orderid= d.orderid GROUP BY g.CategoryID,g.categoryname,Month(o.orderdate)"
        Set oRs = Server.CreateObject("ADODB.Recordset")
        oRs.Open strSQL, oConn
        While not oRs.EOF
            if catXMLDone=false then                        
                strCat = strCat & "<category label='" & MonthName(oRs("MonthNum"),true) & "' />"               
            end if   
            strLink = Server.URLEncode("javaScript:updateProductChart(" & intYear & "," & oRs("MonthNum") & "," & ors("CategoryId") & ");")
            strDataXML = strDataXML & "<set value='" & oRs("Total") & "' link='" & strLink & "'/>"
            oRs.MoveNext
        Wend   
        catXMLDone = true
        Set oRs = nothing
        strDataXML = strDataXML & "</dataset>"
        oRsCat.MoveNext()        
    Wend
    strCat = strCat & "</categories>"
    Set oRsCat = nothing
    strXML = strCat & strDataXML
    getCumulativeSalesByCatXML = strXML
End Function


特别是这个:
strSQL = "SELECT  Month(o.orderdate) as MonthNum, g.CategoryID, g.CategoryName, round(sum(d.quantity),0) as quantity, SUM(d.quantity*p.Unitprice) As Total FROM FC_categories as g,  FC_products as p, FC_orders as o, FC_OrderDetails as d  WHERE year(o.OrderDate)=" & intYear &" and g.categoryId=" & oRsCat("CategoryId") & " and d.productid= p.productid and g.categoryid= p.categoryid and o.orderid= d.orderid GROUP BY g.CategoryID,g.categoryname,Month(o.orderdate)"
搜索更多相关主题的帖子: 代码 asp 注释 
2009-09-17 11:33
hp3325
Rank: 2
等 级:论坛游民
帖 子:29
专家分:26
注 册:2009-6-7
得分:0 
特别是这段:
        strSQL = "SELECT  Month(o.orderdate) as MonthNum, g.CategoryID, g.CategoryName, round(sum(d.quantity),0) as quantity, SUM(d.quantity*p.Unitprice) As Total FROM FC_categories as g,  FC_products as p, FC_orders as o, FC_OrderDetails as d  WHERE year(o.OrderDate)=" & intYear &" and g.categoryId=" & oRsCat("CategoryId") & " and d.productid= p.productid and g.categoryid= p.categoryid and o.orderid= d.orderid GROUP BY g.CategoryID,g.categoryname,Month(o.orderdate)"
2009-09-17 20:50
hp3325
Rank: 2
等 级:论坛游民
帖 子:29
专家分:26
注 册:2009-6-7
得分:0 
解决了,谢谢
2009-09-19 09:57



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-285999-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.152190 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved