Update just 'Comments' MembershipUser Property RRS feed

  • Question

  • User-906895970 posted

    I am trying to update just the 'Comments' property in ASP. NET MembershipUser and want to leave all other property untouched. Here is my codes

    MembershipUser userComments = Membership.GetUser(sUserName);
    userComments.Comment = "Need Change Password";

    It throws an expection 'The E-mail supplied already exists in the database for the application' at Membership.UpdateUser(userComments);

    How can I just update only the 'Comments' without changing emails or any other properties?

    Monday, April 27, 2020 7:33 PM

All replies

  • User-1330468790 posted

    Hi shajigeorge,


    It seems like the exception should be thrown by Membership.CreateUser() rather than UpdateUser().

    The UpdateUser method will only throw ArgumentNullException and the CreateUser method will be able to give a MembershipCreateUserException which contains MembershipCreateStatus Enum. In the enumeration, you could find below code and status.

    DuplicateEmail	7	
    The email address already exists in the database for the application.
    DuplicateProviderUserKey	10	
    The provider user key already exists in the database for the application.
    DuplicateUserName	6	
    The user name already exists in the database for the application.
    InvalidAnswer	4	
    The password answer is not formatted correctly.
    InvalidEmail	5	
    The email address is not formatted correctly.
    InvalidPassword	2	
    The password is not formatted correctly.
    InvalidProviderUserKey	9	
    The provider user key is of an invalid type or format.
    InvalidQuestion	3	
    The password question is not formatted correctly.
    InvalidUserName	1	
    The user name was not found in the database.
    ProviderError	11	
    The provider returned an error that is not described by other MembershipCreateStatus enumeration values.
    Success	0	
    The user was successfully created.
    UserRejected	8	
    The user was not created, for a reason defined by the provider.


    Could you please share the detailed error/exception message? 


    Moreover, if you are using forms authentication with membership, I suggest you use ASP.NET Identity. According to Microsoft, the former ASP.NET Membership has been replaced with ASP.NET Identity.


    Hope this can help you.

    Best regards,


    Wednesday, April 29, 2020 9:44 AM