SqlMembershipProvider::UpdateUser Method (MembershipUser^)

 

Updates information about a user in the SQL Server membership database.

Namespace:   System.Web.Security
Assembly:  System.Web (in System.Web.dll)

public:
virtual void UpdateUser(
	MembershipUser^ user
) override

Parameters

user
Type: System.Web.Security::MembershipUser^

A MembershipUser object that represents the user to update and the updated information for the user.

Exception Condition
System::ArgumentNullException

user is null.

- or -

The UserName property of user is null.

- or -

The Email property of user is null and RequiresUniqueEmail is set to true.

System::ArgumentException

The UserName property of user is an empty string (""), contains a comma, or is longer than 256 characters.

- or -

The Email property of user is longer than 256 characters.

- or -

The Email property of user is an empty string and RequiresUniqueEmail is set to true.

System.Configuration.Provider::ProviderException

The UserName property of user was not found in the database.

- or -

The Email property of user was equal to an existing e-mail address in the database and RequiresUniqueEmail is set to true.

- or -

The user update failed.

This method is called by the Membership class to update user information for a user in the SQL Server database specified in the ASP.NET application's configuration file (Web.config). The Email, Comment, IsApproved, LastLoginDate, and LastActivityDate property values are updated for the specified membership user.

The maximum length for the UserName property is 256 characters. The maximum length for the Email property is 256 characters.

The password for a membership user cannot be updated using the UpdateUser method. To update the password for a membership user, use the ChangePassword method of the MembershipUser class.

The following code example updates the e-mail address for a user.

System_CAPS_noteNote

This example uses the Membership class to call the SqlMembershipProvider specified as the defaultProvider in the Web.config file. If you need to access the default provider as the type SqlMembershipProvider, you can cast the Provider property of the Membership class. To access other configured providers as a specific provider type, you can access them by their configured name with the Providers property of the Membership class and cast them as the specific provider type.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: