none
关于系统登录!!!! RRS feed

  • 问题

  • Const MaxLogTimes As Integer = 3

    Private Sub cmdCancel_Click()
        Dim intResult As Integer    '请求用户认证是否真的退出系统
           
            intResult = MsgBox("你选择了退出系统登录,退出将不能启动管理系统!" & vbCrLf & "是否真得退出?" _
            , vbYesNo, "登录验证")
           
            If intResult = vbYes Then End  '根据用户选择退出应用程序
           
    End Sub

    Private Function Check_PassWord(ByVal UserName As String, ByVal PassWord As String) As Byte
        On Error GoTo goerror
        Dim objCn As Connection, objRs As New Recordset, strCn As String
        Dim strSQL As String
        '建立数据库连接
        objCn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;" & _
                                    "Data Source=" & App.Path & "\实例一.mdb"
        objCn.Open
        '执行查询命令,获得用户登录口令
        strSQL = "select 口令 from 系统用户 where 用户名=" & UserName & ""
        Set objRs.ActiveConnection = objCn
        objRs.Open (strSQL)
        '判断有无查询结果
        If objRs.EOF Then
            Check_PassWord = 0          '没有查询结果,表示该用户为非法用户
        Else
            '检查口令是否正确
            If PassWord <> Trim(objRs.Fields("口令").Value) Then
                Check_PassWord = 1      '口令不正确
            Else
                Check_PassWord = 2      '口令正确
            End If
        End If
        '关闭数据库连接,释放对象
        objCn.Close
        Set objRs = Nothing
        Set objCn = Nothing

        Exit Function

    goerror:
        Check_PassWord = 255
        Set objRs = Nothing
        Set objCn = Nothing
       
        End Function
       
           
       


    Private Sub cmdOK_Click()
        Static intLonTimes As Integer
        Dim intChecked As Integer, strName As String, strPassword As String
        intlogtimes = intlogtimes + 1
       
        If intlogtimes > MaxLogTimes Then   '超过充许的登录次数,显示提示信息
           
            MsgBox "你已经超过充许验证次数!" & vbCr & "应用程序装将结束!", vbCritical, "登录验证"
        Else
            '进一步验证登录信息合法性
           
            strName = Trim(txtUserName.Text)
            strPassword = Trim(txtPassWord.Text)
            '检验用户名和口令的合法性,并根据检验返回值执行相应的操作
           
            Select Case Check_PassWord(strName, strPassword)
           
                Case 0                   '用户不是系统用户
                    MsgBox "<" & strName & _
                    ">不是系统用户,请检查用户名输入是否正确!", vbCritical, "登录验证"
                   
                        txtUserName.SetFocus
                        txtUserName.SelStart = 0
                        txtUserName.SelLength = (txtUserName.Text)
                Case 1                  '口令错误
                   
                    MsgBox "口令错误,请重新输入!", vbCritical, "系统登录"
                   
                        txtPassWord.Text = ""
                        txtPassWord.SetFocus
                Case 2                 '登录成功
               
                    Unload Me          '卸载登录窗体
                    MsgBox "登录成功,将启动登录程序!", vbCritical, "系统登录"
                           
                    '通常在此放置显示系统主窗体语句,例如
                    frmMain.Show
                Case Else             '登录验证未正常完成
                    MsgBox "登录验证未正常完成,请重新运行登录程序!" & vbCrLf _
                             & "如果还不能登录请报告系统登录员!", vbCritical, "登录验证"
                End Select
       
            End If
    End Sub

    在执行那个函数过程的时候,不知道为什么,不能继续往下执行了,直接就跳到错误处理程序段了???????????


    objCn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;" & _
                                    "Data Source=" & App.Path & "\实例一.mdb"

    在这里出错!!!!!!!!!!

    • 已移动 baobaonanModerator 2011年5月23日 1:46 VB.net开发 (发件人:SQL Server)
    2011年5月21日 8:54

答案

全部回复