Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void LoginButton_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- SqlConnection conn = new SqlConnection("Data Source=DB;Initial Catalog=projectDB;User ID=username;Password=password");
- SqlDataAdapter sqa = new SqlDataAdapter("SELECT COUNT(*) FROM user WHERE userName = '" + UsernameTextBox.Text + "' AND password = '" + PasswordTextBox.Password + "'", conn);
- DataTable dt = new DataTable();
- sqa.Fill(dt);
- if (dt.Rows[0][0].ToString() == "1")
- {
- this.Hide();
- }
- else
- {
- MessageBox.Show("Username/Password is incorrect. Please try again");
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
Add Comment
Please, Sign In to add comment