在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))