Advertisement
Guest User

Untitled

a guest
Sep 17th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. protected void Button1_Click(object sender, EventArgs e)
  2. {
  3. SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
  4. con.Open();
  5.  
  6. string query = "select * from login where user_login='" + txtuser.Text+ "' and '" + txtpass.Text + "' ";
  7.  
  8. SqlCommand cmd = new SqlCommand(query, con);
  9.  
  10. string output = cmd.ExecuteScalar().ToString();
  11.  
  12. if (output == "0")
  13. {
  14. Session["user"] = txtuser.Text;
  15. Response.Redirect("");
  16. }
  17. else
  18. Response.Write("Login Failed");
  19. }
  20.  
  21. and user_password = '" + txtpass.Text + "' ";
  22.  
  23. SELECT * FROM UserLogin WHERE Username = @Username AND Password = @Password
  24.  
  25. SqlCommand cmd = new SqlCommand(sql, sqlcon);
  26. using (cmd)
  27. {
  28. sqlcom.Parameters.Add(new SqlParameter("@Username", TextBox1.Text));
  29. string output = cmd.ExecuteScalar().ToString();
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement