Answer:
Here is script
1. USE [DataBaseName]
2. GO
3.
4. DECLARE @return_value int,
5. @NumTablesDeletedFrom int
6.
7. EXEC @return_value = [dbo].[aspnet_Users_DeleteUser]
8. @ApplicationName = N'/',
9. @UserName = N'UserName',
10.@TablesToDeleteFrom = 15,
11.@NumTablesDeletedFrom = @NumTablesDeletedFrom OUTPUT
12.
13.SELECT @NumTablesDeletedFrom as N'@NumTablesDeletedFrom'
14.
15.SELECT 'Return Value' = @return_value
16.
17.GO
Comment Let’s look at @TablesToDeleteFrom parameter. This parameter is a bit mask that specifies which provider database tables the user should be deleted from. The allowed values are:
Value Bit mask Table to delete from
1 0001 aspnet_Membership
2 0010 aspnet_UsersinRoles
4 0100 aspnet_Profile
8 1000 aspnet_PersonalizationPerUser
15 1111 Delete from all tables + aspnet_Users
and combinations!
aspnet_Users_DeleteUser uses a database transaction to ensure that the deletions are performed in whole or not at all.
At first it is bit confusing! You will set a @TablesToDeleteFrom parameter value to 15 and return value @NumTablesDeletedFrom can be just 2 (Deleted from aspnet_Membership and aspnet_Users) !
If you are using SqlMembershipPriver you will find MSDN article http://msdn2.microsoft.com/en-us/library/aa478949.aspx very interesting.
No comments:
Post a Comment