已知四张表:
select pronum from [ProjectReg]
select pronum,pronum1 from [ProjectJiZai]
select pronum,pronum1,pronum2 from [rollreg]
select pronum,pronum1,pronum2,pronum3 from [filesreg]
----------------------------------------------------------SQL查询结果
A
A 22222
A 22222
A 22222 33
A 22222 44
A 22222 33 333
A 22222 44 444
--------------------------------------先用VB的TreeVieww生成四级树
A
22222
33
333
44
444
--------------------------------------下面是实现代码:
'根据现有数据库结构生成四级目录树TreeView
Private Sub LoadFromTable()
Dim oNodex As ComctlLib.Node
Dim nImage, nImage1, nImage2, nImage3 As String
TreeView1.Nodes.Clear
Set mRS = cnMain.Execute("select pronum from [ProjectReg]")
If mRS.RecordCount > 0 Then
mRS.MoveFirst
Do While mRS.EOF = False
nImage = mRS.Fields("pronum")
'一级目录开始
Set oNodex = TreeView1.Nodes.Add(, , "R", nImage, 1)
'二级目录开始
Set mRS1 = cnMain.Execute("select distinct pronum1 as pronum1 from [ProjectJiZai] where pronum='" & nImage & "'")
If mRS1.RecordCount > 0 Then