Advertisement
Guest User

Untitled

a guest
Jun 1st, 2016
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. private void btnLogIn_Click(object sender, EventArgs e)
  2. {
  3. //ekserastikh2016_1_6.Properties.Settings.Database1ConnectionString
  4. SqlConnection customConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ekserastikh2016_1_6.Properties.Settings.Database1ConnectionString"].ConnectionString);
  5. customConnection.Open();
  6. string checkUsername = "select count(*) from [Table] where Username='" + textBox1.Text + "'";
  7. SqlCommand com = new SqlCommand(checkUsername, customConnection);
  8. int a = Convert.ToInt32(com.ExecuteScalar().ToString());
  9. customConnection.Close();
  10. if (a == 1)
  11. {
  12. customConnection.Open();
  13. string checkPassword = "select Password from [Table] where Username='" + textBox2.Text + "'";
  14. SqlCommand p = new SqlCommand(checkPassword, customConnection);
  15. string pass = p.ExecuteScalar().ToString();
  16. if (pass == textBox2.Text)
  17. { MessageBox.Show("hello"); }
  18. else
  19. { MessageBox.Show("Wrong Username or password"); }
  20. }
  21. else
  22. {
  23. MessageBox.Show("Wrong Username or password From (If (a==1)else)");
  24. }
  25.  
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement