急急!求助vb下想用treeview显示sql2005数据库中表的内容!具体如下:
我有1个表想利用treeview显示表里所有字段A的值为1的字段B的信息并且利用一个lable控件显示具体的信息!...
我有1个表想利用treeview显示表里所有字段A的值为1的字段B的信息并且利用一个lable控件显示具体的信息!
展开
展开全部
Sub sub_LoadTreeview()
Dim oAdorst As New ADODB.Recordset
Dim sStr, sA, sB
On Error Resume Next
With Me.Obj_TreeView
.Visible = False
.Nodes.Clear
.Nodes.Add , , "K0", Me.TreeViewRootValue, 1 ' 生成根节点、
'sstr 是你的查询sql语句
sstr="select id,字段B from tablex where 字段a=1"
oAdorst.Open sStr, Me.Obj_dbCon, adOpenKeyset, adLockOptimistic
If Not oAdorst.BOF And Not oAdorst.EOF Then
oAdorst.MoveFirst
Do While Not oAdorst.EOF
.Nodes.Add "K" & Trim(oAdorst.Fields("id")), tvwChild, "K0" , Trim(oAdorst.Fields("字段B"))
oAdorst.MoveNext
Loop
End If
.Visible = True
End With
End Sub
Dim oAdorst As New ADODB.Recordset
Dim sStr, sA, sB
On Error Resume Next
With Me.Obj_TreeView
.Visible = False
.Nodes.Clear
.Nodes.Add , , "K0", Me.TreeViewRootValue, 1 ' 生成根节点、
'sstr 是你的查询sql语句
sstr="select id,字段B from tablex where 字段a=1"
oAdorst.Open sStr, Me.Obj_dbCon, adOpenKeyset, adLockOptimistic
If Not oAdorst.BOF And Not oAdorst.EOF Then
oAdorst.MoveFirst
Do While Not oAdorst.EOF
.Nodes.Add "K" & Trim(oAdorst.Fields("id")), tvwChild, "K0" , Trim(oAdorst.Fields("字段B"))
oAdorst.MoveNext
Loop
End If
.Visible = True
End With
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询