您的位置:首页 > 其它

登陆?登录?

2016-05-26 17:13 197 查看
Option Explicit

Const MaxLoginTimes As Integer = 3

Private Sub cmdLogin_Click()

Static loginTimes As Integer

loginTimes = loginTimes + 1

If loginTimes < MaxLoginTimes Then

On Error GoTo ppp

Dim Cn As Connection

Dim Rs As Recordset

Dim strSQL As String

Set Cn = New Connection

Set Rs = New Recordset

Cn.ConnectionString = " provider=Microsoft.Jet.OLEDB.3.51;Data Source=C:\Users\jf\Desktop\TestExample.mdb"

Cn.Open

Rs.ActiveConnection = Cn

strSQL = "select UserPassword from UserInformation where UserID= '" & Me.txtUserID.Text & "'"

Rs.Open (strSQL)

If Rs.EOF = True Then

MsgBox txtUserID.Text & "不存在"

Me.txtUserID.SetFocus

Me.txtUserID.SelStart = 0

Me.txtUserID.SelLength = Len(Me.txtUserID.Text)

Else

If Rs.Fields("UserPassword").Value = Me.txtPassword.Text Then

MsgBox "登录成功"

Unload Me

'frmNew.show

Else

MsgBox "密码错误"

End If

End If

ppp:

Cn.Close

Else

MsgBox "亲,您的输入次数超过允许的最大次数", vbCritical, "登录"

End If

End Sub
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: