vb+access(含表1,内有user password字段)怎样实现用户登陆,用adodc?
用adodc
Private Sub cmdOK_Click()
On Error GoTo errh:
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Set rs = cn.Execute("SELECT UserName , Password FROM 超级用户 ")
If rs.EOF Then
rs.Close
Set rs = Nothing
Unload Me
Load FrmMain
Exit Sub
End If
rs.MoveFirst
Dim i As Integer
'校验是否为超级用户
Do
If rs.Fields("UserName") = txtUserName.Text Then
If rs.Fields("Password") = txtPassword.Text Then
UserType = True
LoginSucceeded = True
rs.Close
If txtPassword.Text = "Admin" Then IsAdmin = True
Unload Me
Load FrmMain
Exit Sub
Exit Do
End If
End If
rs.MoveNext
Loop Until rs.EOF
'校验是否为普通用户
Set rs = cn.Execute("SELECT 学号 FROM 学生 WHERE 学号 =" & "'" & txtPassword.Text & "'")
If rs.EOF Then
MsgBox "无效密码或用户名请重试!", , "Login"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
Else
rs.Close
UserType = False
LoginSucceeded = True
Unload Me
Load FrmMain
End If
Exit Sub
errh:
MsgBox Err.Description
End Sub