treeview 不是数据约束控件,无法连接数据库!
表名就自动地作为一个节点了,各个字段就是一个子节点,记录还是用LISTVIEW来显示了!
呵呵
具体的范例看MSDN了,
表名就自动地作为一个节点了,各个字段就是一个子节点,记录还是用LISTVIEW来显示了!
呵呵
具体的范例看MSDN了,
解决方案 »
- 怎么切换工作簿的窗口!
- vb的combobox控件如何接受系统默认字体
- 关于timer控件的问题
- 请问如何调用系统程序Packager
- 郁闷!为啥MAPI老提示,JMAIL在VB中老出错?
- 用VB开发Autocad2000的书在那里有的找?? ---在线等待
- 要使VB6能访问ACCESS2000数据库是不是有什么补丁?
- 动态的添加richtextbox数组,为何加完后单击它会出现非法操作和堆栈溢出?而textbox就不会出现非法操作?
- 各位大侠赐教:如何用VB实现多通道的数据采集
- 求教!
- 关于vb数据库的问题!!
- 如何用vb调用sql server中带有参数的存储过程,不用ado控件,只能用数据环境。
你可以通过点击treeview的各个节点,增加一个datagrid空间,然后通过点击各个节点,显示不同数据库的不同表,可以通过代码动态的把datagrid连接到数据库的!我刚刚做完这方面的内容!!
Dim adoxCatalog As New ADOX.Catalog
adoConnection.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=northwind;Server="
'adoConnection.Open "Provider=MSDAORA.1;User ID=internal;Data Source=namepipe1;Persist Security Info=False"
'adoConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Office2K\Office\Samples\Northwind.mdb;Persist Security Info=False"
adoxCatalog.ActiveConnection = adoConnection
'TreeView1.LineStyle = tvwRootLines
TreeView1.Indentation = 400
TreeView1.Nodes.Add , , "DataBase", "数据库: " & adoConnection.DefaultDatabase
TreeView1.Nodes.Add "DataBase", tvwChild, "Table", "基本表"
TreeView1.Nodes.Add "DataBase", tvwChild, "View", "视图"
TreeView1.Nodes.Add "DataBase", tvwChild, "SystemTable", "系统表"
'TreeView1.Nodes.Add "DataBase", tvwChild, "AccessTable", "Access 表"
TreeView1.Nodes.Add "DataBase", tvwChild, "Object", "其它对象"
Dim i As Integer
Dim j As Integer
Dim NodeX As Node
For i = 0 To adoxCatalog.Tables.Count - 1
'Debug.Print adoxCatalog.Tables.Item(i).Type
Select Case adoxCatalog.Tables.Item(i).Type
Case "TABLE"
Set NodeX = TreeView1.Nodes.Add("Table", tvwChild, adoxCatalog.Tables.Item(i).Name, adoxCatalog.Tables.Item(i).Name)
NodeX.Tag = adoxCatalog.Tables.Item(i).Type
Case "VIEW"
Set NodeX = TreeView1.Nodes.Add("View", tvwChild, adoxCatalog.Tables.Item(i).Name, adoxCatalog.Tables.Item(i).Name)
NodeX.Tag = adoxCatalog.Tables.Item(i).Type
Case "SYSTEM TABLE"
Set NodeX = TreeView1.Nodes.Add("SystemTable", tvwChild, adoxCatalog.Tables.Item(i).Name, adoxCatalog.Tables.Item(i).Name)
NodeX.Tag = adoxCatalog.Tables.Item(i).Type
'Case "ACCESS TABLE"
' TreeView1.Nodes.Add "AccessTable", tvwChild, adoxCatalog.Tables.Item(i).Name, adoxCatalog.Tables.Item(i).Name
Case Else
Set NodeX = TreeView1.Nodes.Add("Object", tvwChild, adoxCatalog.Tables.Item(i).Name, adoxCatalog.Tables.Item(i).Name)
NodeX.Tag = "Object"
End Select For j = 0 To adoxCatalog.Tables.Item(i).Columns.Count - 1
Set NodeX = TreeView1.Nodes.Add(adoxCatalog.Tables.Item(i).Name, tvwChild, adoxCatalog.Tables.Item(i).Name & adoxCatalog.Tables.Item(i).Columns.Item(j).Name, adoxCatalog.Tables.Item(i).Columns.Item(j).Name)
Next j
Next i
TreeView1.Nodes.Add "DataBase", tvwChild, "StoreProcedure", "存储过程"
For i = 0 To adoxCatalog.Procedures.Count - 1
Set NodeX = TreeView1.Nodes.Add("StoreProcedure", tvwChild, adoxCatalog.Procedures.Item(i).Name, adoxCatalog.Procedures.Item(i).Name)
Next i