以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- SQLGroupTableBuilder问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=176504) |
-- 作者:qaz17909 -- 发布时间:2022/4/15 14:57:00 -- SQLGroupTableBuilder问题 在HttpRequest中返回统计数据,以下两段代码,测试第一段代码可以返回统计数据,但是无法返回汇总行的值,第二段代码无法返回统计数据,这个应该怎么改,希望能返回含有汇总行的所有数据。 代码一: Dim g As New SQLGroupTableBuilder("统计表1", "查询") g.ConnectionName = wbsjy g.Groups.AddDef("类别") g.Totals.AddDef("数量") g.Subtotal = True Dim dt As DataTable = g.Build(True) \'生成一个DataTable Dim arr As new JArray For Each dr As DataRow In dt.DataRows Dim obj As new JObject For Each dc As DataCol In dt.DataCols obj(dc.Name) = dr(dc.Name).ToString() Next arr.Add(obj) Next e.WriteString(CompressJson(arr)) 代码二: Dim g As New SQLGroupTableBuilder("统计表1", "查询")
g.ConnectionName = wbsjy g.Groups.AddDef("类别") g.Totals.AddDef("数量") g.Subtotal = True g.build() Dim t As Table = Tables("统计表1") Dim arr As new JArray For i As Integer = 0 To t.Rows.Count(True)-1 Dim obj As new JObject For Each c As Col In t.Cols obj(c.Name) = r(c.Name).ToString() Next arr.Add(obj) Next e.WriteString(CompressJson(arr)) |
-- 作者:有点蓝 -- 发布时间:2022/4/15 15:10:00 -- 汇总要另外使用代码统计,比如 Dim jo As new JObject jo("类别") = "合计" jo("数量") = dt.compute("sum(数量)") arr.Add(jo) e.WriteString(CompressJson(arr))
|