蓝老师,外部数据源加载树窗口代码如下:提示错误,不知原因请指导一下
'统计加载树,首先生成统计表
Dim dt As DataTable
Dim b As New SQLGroupTableBuilder("统计表1", "档案")
b.ConnectionName
= "本机Acc" '外部数据源
b.Groups.AddDef("部门ID")
b.Groups.AddDef("日期", DateGroupEnum.Year, "年")
b.Groups.AddDef("日期", DateGroupEnum.Month, "月")
b.Groups.AddDef("日期", DateGroupEnum.Day, "日")
b.Groups.AddDef("销售方名称")
b.Totals.AddDef("_Identify",
AggregateEnum.Count, "张数")
dt = b.Build(False) '参数设置为False,生成一个临时表,不在主界面显示
'然后根据统计表生成目录树
Dim trv As WinForm.TreeView
= e.Form.Controls("TreeView1")
trv.BuildTree(dt, "部门ID|年|月|日|销售方名称")
trv.StopRedraw
For Each nd As WinForm.TreeNode In trv.AllNodes
Dim Product As String =
nd.DataRow("部门ID")
Dim Year As Integer =
nd.DataRow("年")
Dim Month As Integer =
nd.DataRow("月")
Dim Day As Integer =
nd.DataRow("日")
'Dim Product As
String = nd.DataRow("销方名称")
Select Case nd.Level
Case 0
nd.Text
= nd.text & "(" & dt.Compute("Sum(张数)", "部门ID = '" &
Product & "'") & "张)"
Case 1
nd.Text
= nd.text & "年(" &
dt.Compute("Sum(张数)", "部门ID = '" &
Product & "' and 年 = " & Year)
& "张)"
Case 2
nd.Text
= nd.text & "月(" &
dt.Compute("Sum(张数)", "部门ID = '" &
Product & "' and 年 = " & Year
& " And 月 = " & Month) & "张)"
Case 3
nd.Text
= nd.text & "日(" &
dt.Compute("Sum(张数)", "部门ID = '" &
Product & "' and 年 = " & Year
& " And 月 = " & Month & " And 日 = " & Day) & "张)"
Case 4
nd.Text
= nd.text & "(" & nd.DataRow("张数") & ")"
End Select
Next
trv.Nodes.Insert("加载所有行", "加载所有行(" &
dt.Compute("Sum(张数)") & "张)", 0)
trv.ResumeRedraw