'生成统计表
Dim dt As DataTable
Dim b As New sqlGroupTableBuilder("total","员工家庭")
b.ConnectionName
= "HaiHeBase"
b.filter
= ""
b.Groups.AddDef("房产现状")
b.Groups.AddDef("部门村居")
b.Groups.AddDef("所站办组")
b.Groups.AddDef("户主姓名")
b.Totals.AddDef("房产现状",AggregateEnum.count,"结构") '根据客户列来统计结构数
dt = b.Build(false) '如果参数设置为False,生成一个临时表,不在主界面显示
'然后根据统计表生成目录树
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dt,"房产现状|部门村居|所站办组|户主姓名")
trv.StopRedraw
For Each nd As WinForm.TreeNode In trv.AllNodes
Dim bm As String = nd.DataRow("部门村居")
Dim sz As String = nd.DataRow("所站办组")
Dim aq As String = nd.DataRow("房产现状")
Dim xm As String = nd.DataRow("户主姓名")
Select Case nd.Level
Case 0
nd.Text = nd.text & "("
& dt.Compute("count(结构)","房产现状 = '" & aq & "'")
& "幢)"
Case 1
nd.Text = nd.text & "("
& dt.Compute("count(结构)","房产现状 = '" & aq & "' and 部门村居 = '"
& bm & "'") & "幢)"
Case 2
nd.Text = nd.text & "("
& dt.Compute("count(结构)","房产现状 = '" & aq & "' and 部门村居 = '"
& bm & "' And 所站办组 = '" & sz & "'")
& "幢)"
Case 3
nd.Text = nd.text & "(" &
dt.Compute("count(结构)","房产现状 = '" & aq & "' and 部门村居 = '" & bm & "' And 所站办组 = '" &
sz & "' And 户主姓名 = '" &
xm & "'") &
"幢)"
End Select
Next
trv.Nodes.Insert("全镇房屋数","全镇房屋数(" & dt.Compute("count(结构)")
& "幢)",0)
trv.ResumeRedraw
Dim t As WinForm.Table = e.Form.Controls("table1")
t.BackColor = Color.Lightblue
DataTables("安全_table1").SysStyles("EmptyArea").BackColor = Color.lightblue
上述代码如果不执行黄底部分,3万条数据,虽然要十几秒,还可以接受,但加入黄底部分,直接停止响应!查了一下,语句没有问题,请高人指点。