treeview 显示ACCESS数据库中的字段
Option Explicit
Private Sub Form_Load()
'工程->引用->选中Microsoft ActiveX Data Objects 2.8 Library
Dim ShuJuKuLianJie As New ADODB.Connection
Dim JiLuJi As New ADODB.Recordset
'连接数据库的代码段
ShuJuKuLianJie.Open 'Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=' & App.Path & '/database/shujuku.mdb'
'自己改动一下上面的路径和文件名即可,其他的代码你不理解照粘贴无妨
'对xingmingbiao表进行查询操作
JiLuJi.Open 'Select * from xingmingbiao', ShuJuKuLianJie
Dim JieDianDongTai As Node '声明对象变量。
tvTreeView.Nodes.Clear '刷新列表时清空项目
Set JieDianDongTai = tvTreeView.Nodes.Add(, , 'Key', '任务')
While Not JiLuJi.EOF
Set JieDianDongTai = tvTreeView.Nodes.Add('Key', tvwChild, 'Key' & JiLuJi!Id, JiLuJi!xingmingziduan)
JiLuJi.MoveNext
Wend
JieDianDongTai.EnsureVisible
End Sub