怎么让access的信息,显示在对应的方本框内?

来源:百度知道 编辑:UC知道 时间:2024/05/03 06:17:58
数据库已经连接,可是我想让数据库的信息,显示在对应的文本框内,这样的代码怎么写?我没有分了,小弟刚开始学习VB,在此谢过了!也帮我解释一下,一面这段代码,谢谢了!
Private Sub xpbutton3_Click()
If ifuser = "4" Then
MsgBox "查询不可在此时进行,当数据显示为文本框可输!", vbInformation, "错误"
Exit Sub
End If
If admin = False Then
MsgBox "非管理员不可使用"
Exit Sub
End If
If Text1.Visible = False Then
Exit Sub
End If
If sts1.State = adStateOpen Then
sts1.Close
End If
sts1.Open "select * from 个人信息 where 学号='" & Text1.Text & "'", cnn, adOpenKeyset, adLockOptimistic, adCmdText
Text1.Text = sts1.Fields(0)
Text2.Text = sts1.Fields(1)
Combo2.Text = sts1.Fields(3)
DTPicker1.Value = sts1.Fields(4)
Combo1.Text = sts1.Fields(5)
Text3.Text = sts1.Fields(6)
DTPicker2.Value = sts1.Fields(7)
Combo3.Text = sts1.Fields(8)
Label9.Visible = True
Label9.Caption = sts1.Fields(9)
combo4.Te

If sts1.State = adStateOpen Then '假如sts1已经打开,则关闭
sts1.Close
End If
sts1.Open "select * from 个人信息 where 学号='" & Text1.Text & "'", cnn, adOpenKeyset, adLockOptimistic, adCmdText '打开sts1数据集
Text1.Text = sts1.Fields(0) '第一个字段的值赋值给text1
Text2.Text = sts1.Fields(1)
Combo2.Text = sts1.Fields(3)
DTPicker1.Value = sts1.Fields(4)
Combo1.Text = sts1.Fields(5)
Text3.Text = sts1.Fields(6)
DTPicker2.Value = sts1.Fields(7)
Combo3.Text = sts1.Fields(8)
Label9.Visible = True
Label9.Caption = sts1.Fields(9)
combo4.Text = sts1.Fields(10)
End Sub