学生信息表有学生编号(是唯一)、学生姓名、身份证号、父亲姓名等,用目录树输入,如果班级有同名怎么处理。请老师指教,谢谢!
Dim dt As DataTable
Dim cmd As New SQLCommand
cmd.CommandText = "Sel ect 班级,学生姓名,a.学生编号 From ({学生信息} a INNER JOIN {缴学费} b ON a.学生编号 = b.学生编号) LEFT JOIN (Sel ect 学生编号 From {学生退费} Where 学期 = '20181' And 退费项目 = '学费') c ON b.学生编号 = c.学生编号 WHERE 学期 = '20181' And c.学生编号 Is Null ORDER BY a.学生编号"
dt = cmd.ExecuteReader()
Dim trv As WinForm.TreeView = Forms("窗口1").Controls("TreeView1")
trv.BuildTree(dt,"班级|学生编号")
trv.StopRedraw '停止绘制目录树
For Each nd As WinForm.TreeNode In trv.AllNodes
If nd.Level = 1 Then
nd.Text = nd.DataRow("学生姓名")
End If
Next
trv.ResumeRedraw '恢复绘制目录树
[此贴子已经被作者于2018/12/25 21:55:20编辑过]