Dim cmd1 As new SQLCommand
cmd1.ConnectionName = "数据源名字"
cmd1.CommandText = "select '按分组' as 分组, 营业区, 营业部, 营业组 from {成员分组} where 营业区 is not null"
cmd1.CommandText &= " union select '按职级', 职级, null, null from {职级} where 职级 is not null"
cmd1.CommandText &= " union select '按来源', 来源, null, null from {等级} where 来源 is not null"
cmd1.CommandText &= " union select '按学历', 学历, null, null from {学历} where 学历 is not null"
cmd1.CommandText &= " union select '按类型', 成员类型, null, null from {成员类型} where 成员类型 is not null"
Dim dt1 As DataTable = cmd1.ExecuteReader
Dim trv2 As WinForm.TreeView = e.Form.Controls("TreeView3")
trv2.BuildTree(dt1, "分组|营业区|营业部|营业组")