SqlRoleProvider.DeleteRole Method (String, Boolean)

 

Removes a role from the role database.

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

override DeleteRole : 
        roleName:string *
        throwOnPopulatedRole:bool -> bool

Parameters

roleName
Type: System.String

The name of the role to delete.

throwOnPopulatedRole
Type: System.Boolean

If true, throws an exception if roleName has one or more members.

Return Value

Type: System.Boolean

true if the role was successfully deleted; otherwise, false.

Exception Condition
System.ArgumentNullException

roleName is null (Nothing in Visual Basic).

System.ArgumentException

roleName is an empty string or contains a comma.

-or-

roleName is longer than 256 characters.

System.Configuration.Provider.ProviderException

roleName has one or more members and throwOnPopulatedRole is true.

-or-

An unknown error occurred while communicating with the database.

The DeleteRole method is called by the Roles class to delete a role from the SQL Server database specified in the ASP.NET application's configuration file (Web.config). When a role is deleted, the list of users associated with that role is also deleted from the database. The user information in the database is not affected.

If throwOnPopulatedRole is true, then an exception will be thrown and the role will not be deleted if the role identified by the roleName parameter has one or more members. If throwOnPopulatedRole is false, then the role will be deleted whether it is empty or not.

The following example deletes a role from the database. For an example of a Web.config file that enables role management, see SqlRoleProvider.

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

.NET Framework
Available since 2.0
Return to top
Show: