VB Access登陆

来源:互联网 发布:单位正交矩阵的性质 编辑:程序博客网 时间:2024/06/07 18:09
If Text1.Text <> "" And Text2.Text <> "" Then   Dim cnn As ADODB.Connection  '定义连接   Dim Rs As ADODB.Recordset   Set cnn = New ADODB.Connection '定义连接   Set Rs = New ADODB.Recordset   Dim strSQL As String   Static trytime As Integercnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _& App.Path & _"\考勤管理系统.mdb;Persist Security Info=False;Jet OLEDB:Database Password=020135" '创建连接"   Rs.Open "select    1    from    [用户信息]    where    用户名称='" _   & Text1.Text & "'    and    用户密码='" & Text2.Text & "'and 用户类型='" _   & Combo1 & "'", cnn, adOpenKeyset, _   adLockBatchOptimistic '对用户输入的用户名、密码和用户类型与数据库进行匹配       If Rs.EOF Then       MsgBox "用户名称或密码错误!", vbOKOnly + vbExclamation, "警告"           Text1.Text = ""           Text2.Text = ""           Text1.SetFocus           trytime = trytime + 1           If trytime >= 3 Then           MsgBox "您已连续输入错误达3次!系统将自动关闭!!", vbExclamation + vbOKOnly, "温馨提示"           cnn.Close           End           Else           Exit Sub        End If     End If