Guest User

Untitled

a guest
Oct 3rd, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. string userName = LoginUser.UserName;
  2. string password = LoginUser.Password;
  3. string comm = "SELECT Username,Password,Clientname,Role FROM Users WHERE Username = '" + userName + "';";
  4. bool rememberUserName = LoginUser.RememberMeSet;
  5.  
  6. SqlConnection conn = new SqlConnection(connstring);
  7. conn.Open();
  8.  
  9. SqlCommand command = new SqlCommand(comm, conn);
  10. SqlDataAdapter da = new SqlDataAdapter(command);
  11. DataTable dt = new DataTable();
  12. da.Fill(dt);
  13. DataRow dr = dt.NewRow();
  14. if (dt != null)
  15. {
  16. //logic
  17. }
  18.  
  19. if (dt.Rows.Count > 0)
  20.  
  21. if(dt != null && dt.Rows.Count > 0)
  22.  
  23. SqlCommand command = new SqlCommand(comm, conn);
  24. using (var reader = command.ExecuteQuery())
  25. {
  26. if (reader.Read())
  27. {
  28. //logic
  29. var userName = reader.GetString(0);
  30. var password = reader.GetString(1);
  31. // etc
  32. }
  33. }
  34.  
  35. try
  36. {
  37. //dataTable operations
  38. }
  39. catch(IndexOutOfRangeException)
  40. {
  41. }
  42.  
  43. if (ds.Tables[0].Rows.Count > 0)
Add Comment
Please, Sign In to add comment