如何使此登录案例敏感?

时间:2016-03-17 07:37:13

标签: vb.net

 Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

        conn = New OleDbConnection("Provider = Microsoft.ace.Oledb.12.0; Data Source = C:\Users\matthew\Desktop\GSCS\Enrollment.accdb")
        conn.Open()

        Dim cmd As OleDbCommand = New OleDbCommand("SELECT  * FROM Login WHERE UserName = '" & txtUserName.Text & "' AND [Password] = '" & txtPassword.Text & "'", conn)
        Dim dr As OleDbDataReader = cmd.ExecuteReader

        Dim userFound As Boolean = False

        While dr.Read()
            userFound = True
            UserName = dr("Username").ToString
            Password = dr("Password").ToString
            LevelOfAccess = dr("LevelOfAccess").ToString
        End While

        If txtUserName.Text = "" Or txtPassword.Text = "" Then
            MessageBox.Show("Some fields missing")

        ElseIf txtPassword.Text.Length < 6 Then
            MessageBox.Show("Password should consists of 6-12 characters", "Error", MessageBoxButtons.OK)

        ElseIf userFound = True Then

            Dim st As String = "INSERT INTO AuditTrail (Username, DateOfUsage, Activity) VALUES ('" & txtUserName.Text & "', '" & Date.Now & "', '" & li & "')"
            Dim cmd1 As New OleDbCommand(st, conn)
            cmd1.ExecuteNonQuery()

            If LevelOfAccess = 1 Then
                DisplayForm(Dashboard, Main.pnlMain)
                MessageBox.Show("Administrator")

            ElseIf LevelOfAccess = 2 Then
                DisplayForm(Dashboard1, Main.pnlMain)
                MessageBox.Show("Employee")
            End If

        Else
            MsgBox("Sorry, username or password not found", MsgBoxStyle.OkOnly, "Invalid Login")
        End If

        conn.Close()
    End Sub

这是我的登录代码,任何人都可以帮助我如何使其区分大小写?没有错误,但它不是区分大小写的。有谁知道如何使这个案例敏感的人?

1 个答案:

答案 0 :(得分:0)

   String.Compare(str1, str2, True))

尝试使用string.compare方法而不只是“=”Sign

像这样:

dim x as integer x=String.Compare(str1, str2, False) if x=0 then 'Put Codes Here If Password Is Correct else 'put Code Here IF password Is Incorrect end if