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
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

这篇博客展示了如何使用VB来创建一个登录界面,并实现登录验证功能。通过连接到数据库,检查用户ID和密码是否匹配,如果超过最大尝试次数,则提示用户登录失败。
最低0.47元/天 解锁文章
1149

被折叠的 条评论
为什么被折叠?



