LN10 Posted April 4, 2012 at 06:02 PM Report Share #447562 Posted April 4, 2012 at 06:02 PM Boas. Gostaria de saber como posso por a minha Password e o Email como Case Sensitive? É que supostamente deveria ser automático, mas se eu inserir os dados em maiusculas ou minusculas, ele entra no site que tou a desenvolver. Link to comment Share on other sites More sharing options...
Caça Posted April 4, 2012 at 07:47 PM Report Share #447591 Posted April 4, 2012 at 07:47 PM Isso tem a haver como a collate base de dados, em que é que está feita? SQL Server? Pedro Martins Não respondo a duvidas por PM Link to comment Share on other sites More sharing options...
LN10 Posted April 4, 2012 at 08:35 PM Author Report Share #447598 Posted April 4, 2012 at 08:35 PM Boa Noite. Sim, foi feito no Microsoft SQL Server 2008 R2, com o Collate, normal de Portugal, o Latin qualquer coisa Link to comment Share on other sites More sharing options...
Caça Posted April 4, 2012 at 08:46 PM Report Share #447602 Posted April 4, 2012 at 08:46 PM Muda a collate para case sensitive na query que estás a fazer. Pedro Martins Não respondo a duvidas por PM Link to comment Share on other sites More sharing options...
LN10 Posted April 4, 2012 at 09:50 PM Author Report Share #447624 Posted April 4, 2012 at 09:50 PM tipo: use exemplo alter table Login alter column Password collate sensitive Link to comment Share on other sites More sharing options...
Caça Posted April 4, 2012 at 10:07 PM Report Share #447626 Posted April 4, 2012 at 10:07 PM Não, tipo isto SELECT * FROM Login WHERE Utilizador = @Utilizador COLLATE Latin1_General_100_CS_AS AND Password = @Password COLLATE Latin1_General_100_CS_AS Pedro Martins Não respondo a duvidas por PM Link to comment Share on other sites More sharing options...
LN10 Posted April 4, 2012 at 10:52 PM Author Report Share #447644 Posted April 4, 2012 at 10:52 PM Ok. Então vou ao SQL Server e ponho aquele codigo. Link to comment Share on other sites More sharing options...
LN10 Posted April 5, 2012 at 07:09 PM Author Report Share #447844 Posted April 5, 2012 at 07:09 PM Usei o codigo mas nao deu nada. Penso que me expliquei mal No site, que estou a desenvolver gostaria que a Password fica-se case sensitive. Do genero, seu eu ao registar, puser uma passe: "AdMin" ao fazer login no programa puser "admin" ou "ADMIN" ele entra na mesma. EU não queria isso Link to comment Share on other sites More sharing options...
Caça Posted April 5, 2012 at 08:29 PM Report Share #447854 Posted April 5, 2012 at 08:29 PM O código que te indiquei contorna isso, onde é que tiveste dificuldade? Como é que estás a fazer login? Pedro Martins Não respondo a duvidas por PM Link to comment Share on other sites More sharing options...
LN10 Posted April 5, 2012 at 08:35 PM Author Report Share #447856 Posted April 5, 2012 at 08:35 PM 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 More sharing options...
Caça Posted April 5, 2012 at 08:52 PM Report Share #447858 Posted April 5, 2012 at 08:52 PM 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 More sharing options...
LN10 Posted April 5, 2012 at 08:54 PM Author Report Share #447861 Posted April 5, 2012 at 08:54 PM Ok. Muito Obrigado. Já ficou resolvido. 😁 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now