Option Explicit
Dim trytime As Integer
Public conn As ADODB.Connection
Private Sub CMD_cancle_Click()
TXT_usename = ""
TXT_password = ""
TXT_usename.SetFocus
End Sub
Private Sub CMD_OK_Click()
If TXT_usename.Text = "" Then
MsgBox "用户名不能为空", vbOKOnly + vbExclamation, "系统提示"
TXT_usename.SetFocus
Exit Sub
End If
If TXT_password.Text = "" Then
MsgBox "密码不能为空", vbOKOnly + vbExclamation, "系统提示"
TXT_password.SetFocus
Exit Sub
End If
Dim strSQL As String
strSQL = "select * from user where usename='" & Trim(TXT_usename) & "' and password='" & Trim(TXT_password) & "'"
Dim RS As New ADODB.Recordset
Set RS = New ADODB.Recordset
RS.Open strSQL, conn, adOpenStatic, adLockReadOnly
With RS
If .EOF Then
trytime = trytime + 1
If trytime >= 3 Then
MsgBox "您已尝试登陆系统三次,均未成功,系统即将关闭", vbOKOnly + vbQuestion, "警告"
Else
MsgBox "您输入的用户名不存在或密码不正确", vbOKOnly + vbQuestion, "警告"
TXT_usename = ""
TXT_password = ""
Exit Sub
End If
Else
Unload Me
Load Form2
Form2.Show
End If
End With
End Sub
Private Sub Form_Load()
trytime = 0
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & App.Path & " \imformation.mdb;Persist Security Info=false"
End Sub
界面如下:
运行后,输入用户名和密码后点击CMD_OK时显示如下
不知是哪个地方有问题,调试时显示在红色部分,大侠帮帮忙
[此贴子已经被作者于2006-12-19 22:33:58编辑过]