|
3#
楼主 |
发表于 2009-8-22 22:10:58
|
只看该作者
本帖最后由 luhao 于 2009-8-22 22:12 编辑
2# djt
但用了以下的代码,加载时就超快。。。。。但提示:type mismatch 出错,只加载一部分,不能完全加载完数据。。。。。
'***********************************************************************************************
' 用数据库表中数据填充树控件
Dim Conn As New ADODB.Connection
Dim Rec As New ADODB.Recordset
Dim nodIndex As Node
Dim strSQL As String
Dim objList As ListItem
Dim i As Integer
On Error GoTo Err_cw
Set Conn = CurrentProject.Connection
'***********************************************************************************************
'设置业务员
strSQL = "SELECT DISTINCT 存货大类名称 FROM 塑胶件存货档案;"
Rec.Open strSQL, Conn, adOpenKeyset, adLockOptimistic
Rec.MoveFirst
With Rec
Do While Not .EOF
Set nodIndex = TreeView.Nodes.Add(, , "a" & Rec.Fields("存货大类名称"), Rec.Fields("存货大类名称"), 1, 2)
nodIndex.Sorted = True
.MoveNext
Loop
End With
Rec.Close
'***********************************************************************************************
'设置地区
strSQL = "SELECT DISTINCT 存货大类名称,规格型号 FROM 塑胶件存货档案;"
Rec.Open strSQL, Conn, adOpenKeyset, adLockOptimistic
Rec.MoveFirst
With Rec
Do While Not .EOF
Set nodIndex = TreeView.Nodes.Add("a" & Rec.Fields("存货大类名称"), tvwChild, "b" & Rec.Fields("存货大类名称") & Rec.Fields("规格型号"), Rec.Fields("规格型号"), 1, 2)
nodIndex.Sorted = True
.MoveNext
Loop
End With
Rec.Close
'***********************************************************
Set Conn = Nothing
Set Rec = Nothing
Exit_cw:
Set Conn = Nothing
Set Rec = Nothing
Exit Sub
Err_cw:
MsgBox Err.Description
Resume Exit_cw
End Sub |
|