•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 456,479 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,794 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 462 | Replies: 0
![]() |
•
•
Join Date: Dec 2007
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
Hi All,
I m working on a vb.net application. Having a form with treeview & datagrid control. My requirement is that I'll populate the treeview control from a SQL server table. I made this one.
The next task is to populate the datagrid control (another SQL Server Table) from a TreeNode Selection. I m not able to find any solution for this. can any one plz help me.
My code for populating the treeview from sql server table is given below
in Form_load
Dim strConn As String = "Server=BACKUPAEC;Database=DASE;Trusted_Connection=yes;" 'Connection String
Dim objConn As New SqlConnection(strConn) 'Conection Object
'Dataset Objects
Dim objDS As New DataSet
Dim objDS1 As New DataSet
'DataAdapters
Dim daMEquip1 As New SqlDataAdapter("SELECT distinct GroupName FROM MasterEquipmentConfig", objConn)
Dim daMEquip2 As New SqlDataAdapter("SELECT GroupName, EquipmentName, EquipmentID FROM MasterEquipmentConfig", objConn)
'Fill Dataset
daMEquip1.Fill(objDS, "MasterEquipmentConfig")
daMEquip2.Fill(objDS1, "MasterEquipmentConfig")
objConn.Close() 'Close Connection
Dim nodeGroup, nodeEquip As TreeNode
Dim rowGroup, rowEquip As DataRow
For Each rowGroup In objDS.Tables("MasterEquipmentConfig").Rows
nodeGroup = New TreeNode
nodeGroup.Text = rowGroup("GroupName")
nodeGroup.ForeColor = Color.Blue
TreeView1.Nodes.Add(nodeGroup)
For Each rowEquip In objDS1.Tables("MasterEquipmentConfig").Rows
If rowGroup("GroupName") = rowEquip("GroupName") Then
nodeEquip = New TreeNode
nodeEquip.Text = rowEquip("EquipmentName")
nodeGroup.Nodes.Add(nodeEquip)
End If
Next
Next
objDS.Dispose()
objDS1.Dispose()
daMEquip1.Dispose()
daMEquip2.Dispose()
objConn.Close()
objConn.Dispose()
I m working on a vb.net application. Having a form with treeview & datagrid control. My requirement is that I'll populate the treeview control from a SQL server table. I made this one.
The next task is to populate the datagrid control (another SQL Server Table) from a TreeNode Selection. I m not able to find any solution for this. can any one plz help me.
My code for populating the treeview from sql server table is given below
in Form_load
Dim strConn As String = "Server=BACKUPAEC;Database=DASE;Trusted_Connection=yes;" 'Connection String
Dim objConn As New SqlConnection(strConn) 'Conection Object
'Dataset Objects
Dim objDS As New DataSet
Dim objDS1 As New DataSet
'DataAdapters
Dim daMEquip1 As New SqlDataAdapter("SELECT distinct GroupName FROM MasterEquipmentConfig", objConn)
Dim daMEquip2 As New SqlDataAdapter("SELECT GroupName, EquipmentName, EquipmentID FROM MasterEquipmentConfig", objConn)
'Fill Dataset
daMEquip1.Fill(objDS, "MasterEquipmentConfig")
daMEquip2.Fill(objDS1, "MasterEquipmentConfig")
objConn.Close() 'Close Connection
Dim nodeGroup, nodeEquip As TreeNode
Dim rowGroup, rowEquip As DataRow
For Each rowGroup In objDS.Tables("MasterEquipmentConfig").Rows
nodeGroup = New TreeNode
nodeGroup.Text = rowGroup("GroupName")
nodeGroup.ForeColor = Color.Blue
TreeView1.Nodes.Add(nodeGroup)
For Each rowEquip In objDS1.Tables("MasterEquipmentConfig").Rows
If rowGroup("GroupName") = rowEquip("GroupName") Then
nodeEquip = New TreeNode
nodeEquip.Text = rowEquip("EquipmentName")
nodeGroup.Nodes.Add(nodeEquip)
End If
Next
Next
objDS.Dispose()
objDS1.Dispose()
daMEquip1.Dispose()
daMEquip2.Dispose()
objConn.Close()
objConn.Dispose()
M Patra
SSE
AISL, India
SSE
AISL, India
![]() |
•
•
•
•
•
•
•
•
DaniWeb VB.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- How can we populate a datagrid in VB.NET? (VB.NET)
- FREE DotNetNuke File Manager, FREE ASP.NET POP3 and more (ASP.NET)
- is this possible? (C#)
Other Threads in the VB.NET Forum
- Previous Thread: Adding Sound
- Next Thread: treeview with datagrid


Linear Mode