Dim sturst As ADODB.Recordset
Private Sub showrst(temp As ADODB.Recordset)
text_id.Text = temp.Fields(0)
text_name.Text = temp.Fields(1)
Text_sex.Text = temp.Fields(2)
Text_class.Text = temp.Fields(3)
End Sub
Public Sub stufrm_Load()
sturst = New ADODB.Recordset
sturst.CursorTyp = adOpenDynamic
sturst.LockType = adLockOptimistic
sturst.Open "students", cn, , , adCmdTable
If sturst.EOF Then
text_id.Text = ""
text_name.Text = ""
Text_sex.Text = ""
Text_class.Text = ""Else
showrst sturst
End If
End Sub
其中cn为模板变量:public cn as adodb.connection