Connecting Tech Pros Worldwide Help | Site Map

runtime error 3265

nurikoAnna's Avatar
Newbie
 
Join Date: Nov 2008
Posts: 26
#1: Jan 11 '09
Expand|Select|Wrap|Line Numbers
  1. Dim rsFaculty As New ADODB.Recordset
  2. Dim rsDepartment As New ADODB.Recordset
  3. Dim oCm As New ADODB.Command
  4.  
  5. Private Sub Disconnect()
  6.    connect.Close
  7. End Sub
  8.  
  9.  
  10.  
  11. Private Sub Form_Load()
  12.  
  13. '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`)")
  14. 'Call connect
  15. 'SQLconnection
  16. Call fillTree
  17.  
  18.  
  19.  
  20.  
  21. End Sub
  22.  
  23.  
  24. Sub fillTree()
  25.  
  26. Dim sqlFaculty As String
  27. Dim sqlDepartment As String
  28. Dim nodeDepartment As Node
  29. Dim nodeFaculty As Node
  30.  
  31.  
  32. sqlDepartment = "SELECT `t_department`.`DepartmentID`FROM `t_department`"
  33. 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`)"
  34.  
  35. tvTreeView.Nodes.Clear
  36. SQLconnection
  37. rsDepartment.Open sqlDepartment, connect, adOpenDynamic, adLockOptimistic
  38.  
  39.     Dim i As Integer, j As Integer
  40.     With rsDepartment
  41.  
  42.         While Not .EOF
  43.                Set nodeDepartment = tvTreeView.Nodes.Add(, , ![Department], ![Department], 1)
  44.             nodeDepartment.Expanded = True
  45.  
  46.              Set rsFaculty = oCm.Execute(, Array(![DepartmentID]))
  47.                 While Not rsFaculty.EOF
  48.                 Set nodeFaculty = tvTreeView.Nodes.Add(nodeDepartment.Index, tvwChild, , rsFaculty![FacultyFName], 1, 1)
  49.                     j = j + 1
  50.                     rsFaculty.MoveNext
  51.                 Wend
  52.                 nodeDepartment.Text = nodeDepartment.Text & "  [" & Trim(Str(j)) & "]"
  53.                 j = 0
  54.             i = i + 1
  55.             .MoveNext
  56.         Wend
  57.     End With
  58.     Disconnect
  59. 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.......
Reply