Jump to content

TextBox Case Sensitive


LN10

Recommended Posts

  protected void btnLogin_Click(object sender, EventArgs e)
        {
            cnReg.Open();

            string tipo;

            SqlCommand consulta = new SqlCommand("Select * from Login where Email='" + txtEmail.Text + "'and Password='" + txtPassword.Text + "'", cnReg);
            SqlDataReader executar = consulta.ExecuteReader();

            if (isEmail(txtEmail.Text) == true)
            {
                if (executar.Read() == true)
                {
                    Session["id"] = executar.GetString(0);

                    tipo = executar.GetString(2);

                    if (tipo == "Cliente")
                        Response.Redirect("Area_Cli.aspx");

                    else if (tipo == "Administrador")
                        Response.Redirect("Area_Admin.aspx");

                    else if (tipo == "Empregado")
                        Response.Redirect("Area_Emp.aspx");

                }
                else
                {
                    lblAviso.Visible = true;
                    lblAviso.Text = "Os Dados inseridos estão Incorrectos. Por favor, verifique-os.";
                    txtEmail.Text = "";
                    txtPassword.Text = "";
                    txtEmail.Focus();
                    cnReg.Close();
                }
            }
            else
            {
                lblAviso.Visible = true;
                lblAviso.Text = "O Email inserido não é válido.";
            }
        }
Link to comment
Share on other sites

Troca

SqlCommand consulta = new SqlCommand("Select * from Login where Email='" + txtEmail.Text + "'and Password='" + txtPassword.Text + "'", cnReg);

por

SqlCommand consulta = new SqlCommand("Select * from Login where Email='" + txtEmail.Text + "' COLLATE Latin1_General_100_CS_AS and Password='" + txtPassword.Text + "' COLLATE Latin1_General_100_CS_AS  ", cnReg);

Pedro Martins

Não respondo a duvidas por PM

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.