Reputation: 1963
I have a Register page, I used the following Walkthrough: Creating a Web Site with Membership and User Login to make my webpage. The problem is the Registration page creates users, but I am clueless about how to delete user accounts from the Database where it gets stored.
Upvotes: 13
Views: 26240
Reputation: 1
Follow below steps :
C:program file / microsoft visual studio 12/
Command prompt
.write the command : devenv /resetuserdata
Upvotes: 0
Reputation: 88044
The membership provider has a DeleteUser method.
http://msdn.microsoft.com/en-us/library/w6b0zxdw.aspx
The following works just as well:
Membership.DeleteUser("username");
If you want a SQL based solution:
Upvotes: 12
Reputation: 15722
For the completeness' sake, here is a solution similar to Yasser's, however, with using the UserName instead of the GUID as the OP has asked:
DECLARE @UserId uniqueidentifier
SET @UserId = (SELECT TOP(1) UserID FROM aspnet_Users
WHERE UserName = 'THE USERNAME OF THE USER HERE')
DELETE FROM aspnet_Profile WHERE UserID = @UserId
DELETE FROM aspnet_UsersInRoles WHERE UserID = @UserId
DELETE FROM aspnet_PersonalizationPerUser WHERE UserID = @UserId
DELETE FROM dbo.aspnet_Membership WHERE UserID = @UserId
DELETE FROM aspnet_users WHERE UserID = @UserId
Note: Base SQL script taken from this blog by Tim Gaunt
Upvotes: 7
Reputation: 47774
Here is a simpler way to delete a user using SQL.
USE ASPNet
GO
DECLARE @UserId uniqueidentifier
SET @UserId = 'THE GUID OF THE USER HERE'
DELETE FROM aspnet_Profile WHERE UserID = @UserId
DELETE FROM aspnet_UsersInRoles WHERE UserID = @UserId
DELETE FROM aspnet_PersonalizationPerUser WHERE UserID = @UserId
DELETE FROM dbo.aspnet_Membership WHERE UserID = @UserId
DELETE FROM aspnet_users WHERE UserID = @UserId
Upvotes: 12
Reputation: 7963
When creating a WebSite that is going to have a Membership manage users and roles, create an Admin/Support Web Page within your site that will be only visible available for Roles that can perform such operations as:
It will come in handy when you have to support your End Users and the problems they are going to face.
Upvotes: 1
Reputation: 33809
On your project (Visual Studio) Top menu > Website > ASP.NET Configurations (Click on this)
It will open the configurations and then Security > Manage Users Do what you need there...
Upvotes: 2