Advertisement
Guest User

Untitled

a guest
Jun 9th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. try
  2. {
  3. if (!(Username_Text.Text == string.Empty))
  4. {
  5. if (!(Password_Text.Text == string.Empty))
  6. {
  7. SqlConnection connection = new SqlConnection("Data Source=ICSD-DB\\ICSDMSSQLSRV;Initial Catalog=icsd14063;Integrated Security=True");
  8. String sqlString = "select * from RegisterUsers where username = '" + Username_Text.Text + "'and pass = '" + GetStringSha256Hash(Password_Text.Text) + "'";
  9. connection.Open();
  10. SqlCommand command = new SqlCommand(sqlString, connection);
  11. SqlDataReader dbr;
  12. dbr = command.ExecuteReader();
  13. int count = 0;
  14. while (dbr.Read())
  15. {
  16. count = count + 1;
  17. }
  18. if (count == 1)
  19. {
  20. MessageBox.Text = ("Username and password is correct.");
  21. Session["Set_Visible"] = "true";
  22. Response.Redirect("Home.aspx?number1=" + Username_Text.Text);
  23. }
  24. else if (count > 1)
  25. {
  26. MessageBox.Text = ("Username and password incorrect.");
  27. }
  28. else
  29. {
  30. MessageBox.Text = ("Username and password incorrect.");
  31. }
  32. }
  33. else
  34. {
  35. MessageBox.Text = ("Password empty.");
  36. }
  37. }
  38. else
  39. {
  40. MessageBox.Text = ("Username empty.");
  41. }
  42. }
  43. catch (Exception ex)
  44. {
  45. MessageBox.Text = ex.ToString();
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement