Private Sub getEntireList()
Try
ModuleUser.frmTestList1.TVTests.Nodes.Clear()
If ModuleUser.frmTestList1.SqlConnectionTest.State = ConnectionState.Closed Then
ModuleUser.frmTestList1.SqlConnectionTest.Open()
End If
[COLOR=darkgreen]'retrieve all categories from table CATEGORY and store into dataset[/COLOR]
ModuleUser.frmTestList1.DSCatList.Clear()
ModuleUser.frmTestList1.SqlDataAdapterCatList.Fill(ModuleUser.frmTestList1.DSCatList)
Dim i, j, curCatID As Integer
Dim curCategory, curTest As String
For i = 0 To ModuleUser.frmTestList1.DSCatList.Tables("CATEGORY").Rows.Count - 1
curCategory = ModuleUser.frmTestList1.DSCatList.Tables("CATEGORY").Rows(i).Item("CNAME").ToString
curCatID = ModuleUser.frmTestList1.DSCatList.Tables("CATEGORY").Rows(i).Item("CID").ToString
[COLOR=darkgreen]'add current category name as a node[/COLOR]
ModuleUser.frmTestList1.TVTests.Nodes.Add(curCategory)
[COLOR=darkgreen]'loop through test, add test under current category where CATEGORY.CID = TEST.CID[/COLOR]
ModuleUser.frmTestList1.SqlSelectCommand2.Parameters("@CID").Value = curCatID
ModuleUser.frmTestList1.DsTestList.Clear()
ModuleUser.frmTestList1.SqlDataAdapterTestList.Fill(ModuleUser.frmTestList1.DsTestList)
For j = 0 To ModuleUser.frmTestList1.DsTestList.Tables("TEST").Rows.Count - 1
[COLOR=darkgreen]'once we have the records we fill the respective child node in the control[/COLOR]
curTest = ModuleUser.frmTestList1.DsTestList.Tables("TEST").Rows(j).Item("TNAME").ToString
Dim TestNode As TreeNode
TestNode = ModuleUser.frmTestList1.TVTests.Nodes(i)
[COLOR=darkgreen]'add current test name as a node[/COLOR]
TestNode.Nodes.Add(curTest)
Next
Next
ModuleUser.frmTestList1.SqlConnectionTest.Close()
Catch Exp As SqlClient.SqlException
MsgBox(Exp.Message, MsgBoxStyle.Critical, "SQL Error")
Catch Exp As Exception
MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub