Samuel Toh

Samuel Toh

  • NA
  • 106
  • 16.4k

Case Sensitivity in winforms c#

Nov 5 2021 10:09 AM

private void btnCustomLogin_Click(object sender, EventArgs e)
        {
            if (txtpassword.Text != string.Empty || txtusername.Text != string.Empty)
            {
                SetValueForText1 = txtusername.Text;

                cmd = new SqlCommand("select * from Login where Username='" + txtusername.Text + "' and Password='" + txtpassword.Text + "'", cn);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    dr.Close();
                    this.Hide();
                    Home home = new Home();
                    home.ShowDialog();
                }
                else
                {
                    dr.Close();
                    this.Alert("No Account available with\nthis Username and Password.", Form_Alert.enmType.Error);
                }

            }
            else
            {
                this.Alert("Please enter value in all field.", Form_Alert.enmType.Error);
            }
        }

 

How do I make both the username and password case sensitive?


Answers (6)