Guest User

Untitled

a guest
Nov 26th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. private void LoginButton_Click(object sender, RoutedEventArgs e)
  2. {
  3. try
  4. {
  5. SqlConnection conn = new SqlConnection("Data Source=DB;Initial Catalog=projectDB;User ID=username;Password=password");
  6. SqlDataAdapter sqa = new SqlDataAdapter("SELECT COUNT(*) FROM user WHERE userName = '" + UsernameTextBox.Text + "' AND password = '" + PasswordTextBox.Password + "'", conn);
  7. DataTable dt = new DataTable();
  8. sqa.Fill(dt);
  9.  
  10. if (dt.Rows[0][0].ToString() == "1")
  11. {
  12. this.Hide();
  13. }
  14. else
  15. {
  16. MessageBox.Show("Username/Password is incorrect. Please try again");
  17. }
  18. }
  19. catch (Exception ex)
  20. {
  21. MessageBox.Show(ex.Message);
  22. }
  23. }
  24. }
Add Comment
Please, Sign In to add comment