Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to Create a Login Form that the fields in password are case sensitive example if my passwords is "PassWord" it will only accepts the keyword "PassWord" and not accepts "password" Or "PASSWORD" keyword etc. I want it a character sensitive thanks Please Help me Im a new Programmer using DATABASE MS ACCESS Thanks Here is my code The Problem is i can't create a log in form that the password field is case sensitive
Private Sub btnLog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLog.Click
    Try
        Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\NIASecurity.accdb")
        Dim cmd As OleDbCommand = New OleDbCommand("SELECT [Username] FROM [Security] WHERE [Username] = @User and Password =@Pass ", con)
        cmd.Parameters.AddWithValue("@User", txtUser.Text)
        cmd.Parameters.AddWithValue("@Pass", txtPass.Text)
        con.Open()
        Dim sdr As OleDbDataReader = cmd.ExecuteReader()
        If sdr.Read Then
            If txtPass.Text = sdr(0) Then
                MessageBox.Show("Welcome")
                Dim win As New frmAdd
                win.MdiParent = frmMDI
                win.Show()
                Me.Close()
            Else
                MsgBox("Invalid name or password!")

            End If
        End If


    Catch ex As Exception
        MessageBox.Show("Invalid name or password!")
    End Try
End Sub
Posted
Updated 6-Feb-23 4:06am
v2
Comments
[no name] 28-Sep-14 13:12pm    
And the problem is....?
Member 11115800 28-Sep-14 14:33pm    
The Problem is i can't create a log in form that the password field is case sensitive
[no name] 28-Sep-14 14:36pm    
How, exactly, is thata problem? Why do you think that it's not already case sensitive?
Sergey Alexandrovich Kryukov 28-Sep-14 13:39pm    
The problem is not clear. All passwords these days are case-sensitive, so what? First of all, don't store password in the database, only store cryptographic hash of passwords. Nobody should know original passwords except people who created them, not even those having full access to the database.
—SA
Member 11115800 28-Sep-14 14:24pm    
The Problem is i can't create a log in form that the password field is case sensitive

1 solution

Read extremely carefully SA's comment! It explain to you why in password you need not care for case-sensitive or insensitive! A hash of HelloWorld is not the same as of helloworld!
For other data (like names in your case) if you want case-sensitive data, you have to choose the right COLLATION[^] for your database or use COLLATE[^] on a single data column/variable to make it case-sensitive or insensitive according your need!!!

Let see some sample...
Imagine we have a database with collation of Latin1_General_CI_AS, which means the Latin1 portion of unicode with case insensitive and accent sensitive comparison...
Now we have a table (Usr) with two columns - PswHash, UserName.
If we want to compare UserName case sensitive (remember the DB is case INsensitive!) we can do it like this...
SQL
SELECT *
FROM Usr
WHERE UserName = @UserName COLLATE Latin1_General_CS_AS;

Where @UserName is the variable holding the user name as written by the user on the login form...
 
Share this answer
 
v2
Comments
Member 11115800 29-Sep-14 2:00am    
But i dont know how to do the COLLATION can anyone help me clearly. Im already a beginner here so im not familiar of some of thing you are telling to me
Kornfeld Eliyahu Peter 29-Sep-14 3:12am    
See updated solution...
Member 11115800 29-Sep-14 3:46am    
where i can put that line of code in my code? thnks so much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900