Guest User

Untitled

a guest
Apr 12th, 2018
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1. protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
  2.         {
  3.  
  4.  
  5.             SqlConnection conn = new SqlConnection("Data Source=sqlserver01.webint.com.br;Initial Catalog=webint;Persist Security Info=True;User ID=webint;Password=igor1990");
  6.  
  7.             string sql = "select email, senha from tb_usuarios where email = @email and senha = @senha)";
  8.  
  9.             try
  10.             {
  11.                 SqlCommand valor = new SqlCommand(sql, conn);
  12.                 valor.Parameters.Add(new SqlParameter("@senha", Login1.Password));
  13.                 valor.Parameters.Add(new SqlParameter("@email", Login1.UserName));
  14.  
  15.                 conn.Open();
  16.                 valor.ExecuteNonQuery();
  17.                 conn.Close();
  18.                 RegisterClientScriptBlock("cadastrado", "<script>alert(Operação concluida !)</script>");
  19.             }
  20.             catch
  21.             {
  22.                 RegisterClientScriptBlock("naoCadastrado", "<script>alert(Operação não concluida !)</script>");
  23.             }
  24.             finally
  25.             {
  26.                 conn.Close();
  27.             }
  28.             /*
  29.             if ((Login1.UserName == "admin")  && (Login1.Password == "123"))
  30.             {
  31.                 e.Authenticated = true;
  32.                 FormsAuthentication.RedirectFromLoginPage(Login1.UserName, false);
  33.                 Response.Redirect("InserirRegistro.aspx");
  34.             }
  35.             else
  36.             {
  37.                 e.Authenticated = false;
  38.             }
  39.              * */
  40.         }
Add Comment
Please, Sign In to add comment