Guest User

Untitled

a guest
Dec 27th, 2018
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. protected void Button1_Click(object sender, EventArgs e)
  2. {
  3. SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=payroll;Integrated Security=True");
  4. SqlCommand cmd = new SqlCommand("Select employeeid FROM employees WHERE username='" + TextBox1.Text + "'and password='"+TextBox2.Text+"'", con);
  5.  
  6. cmd.CommandType = CommandType.Text;
  7. cmd.Parameters.AddWithValue("@username", TextBox1.Text);
  8. cmd.Parameters.AddWithValue("@password", TextBox2.Text);
  9.  
  10. con.Open();
  11.  
  12. SqlDataReader dr = cmd.ExecuteReader();
  13.  
  14. if (dr.Read()) //I'M WRONG FROM HERE ONWARDS.
  15. {
  16. Response.Redirect("Admin.aspx");
  17. }
  18.  
  19. con.Close();
  20. dr.Close();
  21. }
Add Comment
Please, Sign In to add comment