关于登录后显示使用者姓名和权限的问题
Access数据库格式为:
user password name class
1 1 AAA SYS
2 2 BBB OPE
. . . .
. . . .
. . . .
程序源码为:
Private conn As New ADODB.Connection
Private Sub adminlogin()
Static j As Integer
Dim rs As New ADODB.Recordset
SQL = "select username,password from admin Where username='" & text1.Text & "' and password='" & text2.Text & "'"
Set rs = conn.Execute(SQL)
If rs.EOF And rs.BOF Then
j = j + 1
rs.Close
Set rs = Nothing
MsgBox "密码错误"
If j > 2 Then
MsgBox "连续错误3次!程序将退出"
End
End If
Else
rs.Close
Set rs = Nothing
Form2.Show
'在这里增加语句
Unload Me
End If
End Sub
Private Sub Form_Load()
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data.mdb;Mode=ReadWrite|Share Deny None;Persist Security Info=False"
End Sub
Private Sub cmd_Click()
Call adminlogin
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set conn = Nothing
End Sub
Private Sub text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Call adminlogin
End Sub
问题:
想在正确登录后,如用户名为1,密码为1,登录后在Form2.Label1.Caption中显示AAA,Form2.Label2.Caption中显示SYS,语句该怎么写?