Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. if (!string.IsNullOrEmpty(txtUser.Text))
  2. {
  3. string constring = ConfigurationManager.ConnectionStrings["ConnData"].ConnectionString;
  4. SqlConnection con = new SqlConnection(constring);
  5.  
  6. SqlCommand cmd = con.CreateCommand();
  7. cmd.CommandType = CommandType.Text;
  8. cmd.CommandText = "select Username from UserLogin where Username ='" + txtUser.Text + "'";
  9.  
  10. DataTable dt = new DataTable();
  11. SqlDataAdapter da = new SqlDataAdapter(cmd);
  12. da.Fill(dt);
  13.  
  14. if (dt.Rows.Count > 0)
  15. {
  16. txtUser.Clear();
  17. PasswordChange pc = new PasswordChange();
  18. pc.Show();
  19. this.Hide();
  20. return;
  21. }
  22. else
  23. {
  24. MessageBox.Show("Your username incorrect");
  25. }
  26. }
  27. else
  28. {
  29. MessageBox.Show("Please enter your username");
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement