- Dim rsFaculty As New ADODB.Recordset
-
Dim rsDepartment As New ADODB.Recordset
-
Dim oCm As New ADODB.Command
-
-
Private Sub Disconnect()
-
connect.Close
-
End Sub
-
-
-
-
Private Sub Form_Load()
-
-
'connect.Execute ("SELECT `t_faculty`.`FacultyFName`,`t_faculty`.`FacultyMI`,`t_faculty`.`FacultyLName`,`t_faculty`.`DepartmentID`,`t_department`.`Department`FROM `t_faculty`INNER JOIN `t_department` ON (`t_department`.`DepartmentID` = `t_faculty`.`DepartmentID`)")
-
'Call connect
-
'SQLconnection
-
Call fillTree
-
-
-
-
-
End Sub
-
-
-
Sub fillTree()
-
-
Dim sqlFaculty As String
-
Dim sqlDepartment As String
-
Dim nodeDepartment As Node
-
Dim nodeFaculty As Node
-
-
-
sqlDepartment = "SELECT `t_department`.`DepartmentID`FROM `t_department`"
-
sqlFaculty = "SELECT `t_department`.`Department`,`t_faculty`.`FacultyFName`,`t_faculty`.`DepartmentID`FROM `t_faculty`INNER JOIN `t_department` ON (`t_department`.`DepartmentID` = `t_faculty`.`DepartmentID`)"
-
-
tvTreeView.Nodes.Clear
-
SQLconnection
-
rsDepartment.Open sqlDepartment, connect, adOpenDynamic, adLockOptimistic
-
-
Dim i As Integer, j As Integer
-
With rsDepartment
-
-
While Not .EOF
-
Set nodeDepartment = tvTreeView.Nodes.Add(, , ![Department], ![Department], 1)
-
nodeDepartment.Expanded = True
-
-
Set rsFaculty = oCm.Execute(, Array(![DepartmentID]))
-
While Not rsFaculty.EOF
-
Set nodeFaculty = tvTreeView.Nodes.Add(nodeDepartment.Index, tvwChild, , rsFaculty![FacultyFName], 1, 1)
-
j = j + 1
-
rsFaculty.MoveNext
-
Wend
-
nodeDepartment.Text = nodeDepartment.Text & " [" & Trim(Str(j)) & "]"
-
j = 0
-
i = i + 1
-
.MoveNext
-
Wend
-
End With
-
Disconnect
-
End Sub
above are my codes for to populate data in a list view...call data from the database..
Currenty i am using MySQL as a database....
I have a table t_department and another table is t_faculty...What I like to do using a treeview....I want to display in the treeview the parent node as Department name then the child nodes are list of the Faculty names...
and i always got an error :
runtime error 3265
item cannot be found in the collection corresponding to the requested name or cardinal at the underlined line above...
please help.......