Hi Everyone,
Very new to this coding stuff and have been developing my own application. Am now working on the login screen and have this working nicely, except for the fact that username and passwords are accepted despite the case being incorrect.
The username and password is checked against an MDB file I have:
See my code:
I am wanting to insert some code to check both the login name and password for case sensitivity.
What would be the best way to do this? String.Compare ?
Hopefully someone will be able to give me some pointers.. Thanks
Very new to this coding stuff and have been developing my own application. Am now working on the login screen and have this working nicely, except for the fact that username and passwords are accepted despite the case being incorrect.
The username and password is checked against an MDB file I have:
See my code:
VB.NET:
Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
'provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
'Change the following to your access database location
'dataFile = "C:\Users\nickh\Google Drive\SignNET\VisualStudio\SignNET\SignNET.accdb"
'connString = provider & dataFile
myConnection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='C:\Users\nickh\Google Drive\SignNET\VisualStudio\SignNET\SignNET.accdb'"
myConnection.Open()
'the query:
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM [tblStaff] WHERE [StaffLogin] = '" & txtUser.Text & "' AND [StaffPassword] = '" & txtPassword.Text & "'", myConnection)
Dim dr As OleDbDataReader = cmd.ExecuteReader
' the following variable is hold true if user is found, and false if user is not found
Dim userFound As Boolean = False
' the following variables will hold the user first and last name if found.
Dim FirstName As String = ""
Dim LastName As String = ""
'if found:
While dr.Read
userFound = True
FirstName = dr("StaffFirstName").ToString
LastName = dr("StaffLastName").ToString
End While
'checking the result
If userFound = True Then
Me.Close()
MsgBox("Hi " & FirstName & " " & LastName & ". You are now logged on.", vbOK)
frmDash.ShowDialog()
Else
MsgBox("Sorry, username or password not found", MsgBoxStyle.OkOnly, "Invalid Login")
End If
myConnection.Close()
End Sub
I am wanting to insert some code to check both the login name and password for case sensitivity.
What would be the best way to do this? String.Compare ?
Hopefully someone will be able to give me some pointers.. Thanks
Last edited: