Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. protected void Button1_Click(object sender, EventArgs e)
  2. {
  3. SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connect"].ConnectionString);
  4. con.Open();
  5. string checkuser = "select * from tb_Login where Username'" + txtUsername.Text + "' and Password='" + txtPassword.Text + "' ";
  6. SqlCommand com = new SqlCommand(checkuser, con);
  7. int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
  8. con.Close();
  9.  
  10. if (temp == 1)
  11. {
  12. con.Open();
  13. string checkPass = "select Password from tb_Login where Username'" + txtUsername.Text + "'";
  14. SqlCommand passCom = new SqlCommand(checkPass, con);
  15. string password = passCom.ExecuteScalar().ToString().Replace(" ", "");
  16. if (password == txtPassword.Text)
  17. {
  18. Session["New"] = txtUsername.Text;
  19. Response.Write("Correct");
  20. }
  21. else
  22. {
  23. Response.Write("Not Correct");
  24. }
  25. }
  26. else
  27. {
  28. Response.Write("Username not correct");
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement