How does one validate username and password from sql database? I have used parameters in doing validating my database, but have noticed that username and passwords are being accepted when i type it straight out(EG. username= e001 , password=dave@road) , even though they have characters in capital letters(such as username=E001 , password=Dave@Road).
Here is my coding:
Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click
Try
If (txtuname.Text = "-") Or (txtuname.Text = "0") Or (txtuname.Text = "") Or (txtpass.Text = "0") Or (txtpass.Text = "-") Or (txtpass.Text = "") Then
pberror.Visible = True
pberror2.Visible = True
MessageBox.Show("Invalid Entry", "ErrorMessageBox", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtuname.Text = ""
txtpass.Text = ""
pberror.Visible = False
pberror2.Visible = False
Return
End If
empeid = txtuname.Text
DatasetLogin1.Clear()
sqldLoginadapter.SelectCommand.Parameters("@eid").Value = txtuname.Text
sqldLoginadapter.SelectCommand.Parameters("@epass").Value = txtpass.Text
sqldLoginadapter.Fill(DatasetLogin1, "empdetails")
If (DatasetLogin1.Tables("empdetails").Rows.Count > 0) Then
pberror.Visible = False
pberror2.Visible = False
pbright.Visible = True
pbright2.Visible = True
MessageBox.Show("Login Successfull! Welcome Employee: " & empeid, "MessageBox", MessageBoxButtons.OK, MessageBoxIcon.Information)
empeid = lblename.Text
PDL_Main_Menu.NameStrip.Text = empeid
Me.Hide()
PDL_Main_Menu.Show()
Else
pberror.Visible = True
pberror2.Visible = True
MessageBox.Show("Not Registered Employee Details!. Please Try Again", "ErrorMessageBox", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtuname.Text = ""
txtpass.Text = ""
pberror.Visible = False
pberror2.Visible = False
Return
End If
Catch con As SqlClient.SqlException
MessageBox.Show("Error in the connection. Please try again later", "ErrorConnection", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
End Sub
I have connected to my database using sqladapter through the wizard, and set my parameters for username and password .
Is there another simple way that i can do validations of username and password?
Thanks.