gladyssann

UserDataAccess.cs

Jan 8th, 2018
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. public UserEntity DeleteUser(int userId) {
  2.  
  3. SqlConnection oCon = null;
  4. SqlCommand oCmd = null;
  5. UserEntity user = null;
  6.  
  7. try
  8. {
  9. oCon = _connection.openConn();
  10. string sqlDelete = string.Format("DELETE FROM Users WHERE usr_id = @userId");
  11.  
  12. oCmd = new SqlCommand(sqlDelete, oCon);
  13. oCmd.Parameters.Add(new SqlParameter("@userId", user.usr_Id));
  14. oCmd.ExecuteNonQuery();
  15.  
  16. }
  17. catch (Exception ex)
  18. {
  19.  
  20. throw ex;
  21. }
  22.  
  23. return user;
  24. }
Add Comment
Please, Sign In to add comment