Dim myval As String
Dim rs As ADODB.Recordset
Private Sub Form_Load()
Set rs = New ADODB.Recordset '---------------------------------------- Dim ssql As String, arr As Variant strcn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=g:\zyxy\data\student.mdb;Persist Security Info=false" ssql = "SELECT 班级名称 From T_class ORDER BY 入学时间" ' ssql = "select * from job" Set cn = New ADODB.Connection Set rs = New ADODB.Recordset cn.CursorLocation = adUseClient cn.ConnectionString = strcn cn.Open rs.Open ssql, cn, adOpenDynamic, adLockBatchOptimistic ' rs.Open ssql, cn arr = rs.GetRows() ' rs.Close 'fill tv TV.Nodes.Clear On Local Error Resume Next For i% = 0 To UBound(arr, 2) '行数 TV.Nodes.Add , , "X" & arr(0, i), arr(0, i) ' TV.Nodes.Add "X" & arr(0, i), tvwChild, "Z" & arr(1, i), arr(1, i) ' TV.Nodes.Add "Z" & arr(1, i), tvwChild, "B" & arr(2, i), arr(2, i) Next End Sub
Private Sub Form_Unload(Cancel As Integer)
On Local Error Resume Next ' rs.Close ' Set rs = Nothing End Sub
Private Sub TV_NodeClick(ByVal Node As MSComctlLib.Node)
Dim ssql As String ' ssql = "select * from T_class where 班级名称='" & Node.Text & "'" Text1.Text = Node.key
ssql = "select * from T_class where 班级名称='" & Node.Text & "'order by 入学时间" If rs.RecordCount <> 0 Then
'If rs.Fields(i) <> "" Then Text("i").Text = Trim(rs.Recordset.Fields(i)) If .Fields("人数") <> "" Then Text2.Text = rs.Fields("人数") If .Fields("班主任") <> "" Then Text3.Text = rs.Fields("班主任") If .Fields("班长") <> "" Then Text4.Text = rs.Fields("班长") If .Fields("年制") <> "" Then Text5.Text = rs.Fields("年制") If .Fields("备注") <> "" Then Text6.Text = rs.Fields("备注") 'If DTP1.Value <> "" Then rs.Fields("入学时间") = DTP1.Value
End If
End Sub treeview控件没什么问题.可以显示我想要的东西
但是我在对text控件付值的时候为什么老是提示说有问题那,请各位指教下.