| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1016 人关注过本帖
标题:请高手帮助注释一段asp代码,有点难呀
只看楼主 加入收藏
hp3325
Rank: 2
等 级:论坛游民
帖 子:29
专家分:26
注 册:2009-6-7
结帖率:33.33%
收藏
 问题点数:0 回复次数:4 
请高手帮助注释一段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
无根泉
Rank: 2
等 级:新手上路
威 望:4
帖 子:853
专家分:0
注 册:2004-11-4
收藏
得分:0 
FC_categories as g,  FC_products as p, FC_orders as o, FC_OrderDetails as d
四个表用别名表示,
Month(o.orderdate) as MonthNum 取  FC_orders表中orderdate字段的月份
round(sum(d.quantity),0)       求和表FC_OrderDetails中quantity字段并取整数
SUM(d.quantity*p.Unitprice) As Total 将表FC_OrderDetails的字段和FC_products表中的Unitprice字段相乘并求和

我很菜,但我很努力!
2009-09-17 21:12
无根泉
Rank: 2
等 级:新手上路
威 望:4
帖 子:853
专家分:0
注 册:2004-11-4
收藏
得分:0 
year(o.OrderDate)=" & intYear &" and g.categoryId=" & oRsCat("CategoryId") 设定查询条件
 
d.productid= p.productid and g.categoryid= p.categoryid and o.orderid= d.orderid四个表的依赖关系

我很菜,但我很努力!
2009-09-17 21:14
hp3325
Rank: 2
等 级:论坛游民
帖 子:29
专家分:26
注 册:2009-6-7
收藏
得分:0 
解决了,谢谢
2009-09-19 09:57
快速回复:请高手帮助注释一段asp代码,有点难呀
数据加载中...
 
   



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

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