Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. protected void botaoLogin_Click(object sender, EventArgs e)
  2. {
  3. string nome = user.Text;
  4. string senha = senhaa.Text;
  5. Database bd = new Database();
  6. bd.conecta();
  7.  
  8.  
  9. int i = 0;
  10. MySqlCommand cmd = bd.bdConn.CreateCommand();
  11. cmd.CommandType = CommandType.Text;
  12. cmd.CommandText = "select * from tb_usuario where nome_de_usuario='" + nome + "'and senha='" + senha + "'";
  13. cmd.ExecuteNonQuery();
  14.  
  15.  
  16. DataTable dt = new DataTable();
  17. MySqlDataAdapter da = new MySqlDataAdapter(cmd);
  18. da.Fill(dt);
  19. i = Convert.ToInt32(dt.Rows.Count.ToString());
  20.  
  21.  
  22. if (i == 0)
  23. {
  24. ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Falha ao logar usuário.');", true);
  25. }
  26. else
  27. {
  28. ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Usuário logado com sucesso.');", true);
  29. Server.Transfer("index.aspx?autor=" + nome);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement