Advertisement
Guest User

Untitled

a guest
May 5th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. SqlConnection cnn = null;
  2. SqlCommand cmd = null;
  3. SqlDataAdapter sda = null;
  4. DataTable Dt = new DataTable();
  5.  
  6. cnn = new SqlConnection("Server=dbadmin01.database.windows.net;Database=dbadmin;User=info;Password=notGivingThis");
  7. cmd = new SqlCommand("SELECT username FROM users WHERE username =@TextboxValue", cnn);
  8. cnn.Open();
  9. cmd.CommandType = CommandType.Text;
  10. cmd.Parameters.Add("@TextboxValue", SqlDbType.VarChar).Value = txtUser.Text;
  11. sda = new SqlDataAdapter(cmd);
  12. sda.Fill(Dt);
  13.  
  14. if (Dt.Rows.Count > 0)
  15. {
  16. //Works - do nothing for now
  17. }
  18. else
  19. {
  20. MessageBox.Show("Username is incorrect!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
  21. }
  22.  
  23. cnn = new SqlConnection("Server=dbadmin01.database.windows.net;Database=dbadmin;User=info;Password=notGivingThis");
  24. cmd = new SqlCommand("SELECT passcode FROM users WHERE passcode =@PasswordValue", cnn);
  25. cnn.Open();
  26. cmd.CommandType = CommandType.Text;
  27. cmd.Parameters.Add("@PasswordValue", SqlDbType.VarChar).Value = pwdPassword.Password;
  28. sda = new SqlDataAdapter(cmd);
  29. sda.Fill(Dt);
  30.  
  31. if (Dt.Rows.Count > 0)
  32. {
  33. //Works - Do nothing for now
  34. }
  35. else
  36. {
  37. MessageBox.Show("Password is incorrect!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
  38. }
  39.  
  40. SELECT username FROM users WHERE username =@TextboxValue AND passcode =@PasswordValue
  41.  
  42. cmd = new SqlCommand("select Username,passcode from users where username =@username",cnn);
  43.  
  44. if (Dt.Rows[0]["passcode"].ToString()!=pwdPassword.Password)
  45. {
  46. MessageBox.Show("Invalid Password");
  47. return;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement