Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 2.0 and Databases
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 and Databases by John Kauffman, Bradley Millington; ISBN: 9780471781349
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 and Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 23rd, 2008, 12:18 PM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default How to delete a user in ASPNet database

Hi there i have this problem with deleting a user from aspnet db. i am using VS2005
when i try to configure data source on the datasource controll i do not get the generate ,update,insert,delete statment.

i found this on internet
Code:
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
but i dont know what is the guide of user and how to find it.

can any one help me with this

thank
__________________
bx
 
Old December 23rd, 2008, 12:29 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

The UserId can be retrieved from the ProviderUserKey, like this:

CSharp Code:
Guid userId = (Guid)Membership.GetUser().ProviderUserKey;
Visual Basic Code:
Dim userId As Guid = CType(Membership.GetUser().ProviderUserKey, Guid)
But why are you using direct SQL? I think you're much better off using the API:

Code:
Membership.DeleteUser(Membership.GetUser().UserName, True)
Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old December 23rd, 2008, 06:54 PM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

thanks for your replay i never used
Code:
 Membership.DeleteUser(Membership.GetUser().UserName, True)
and i dont know how to implement it can you plase guide me a bit or tell me where can i finde more about it ? (books)
__________________
bx
 
Old December 25th, 2008, 05:15 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

that was quiet easy i found it in begin aspnet 2.0
__________________
bx





Similar Threads
Thread Thread Starter Forum Replies Last Post
User Accounts ASPNET.mdf pschulz ASP.NET 2.0 Basics 3 June 19th, 2008 12:41 PM
Creating a ASPNET user s_boland .NET Web Services 2 June 6th, 2007 02:22 PM
error Login failed for user 'HOME\ASPNET' Raif ASP.NET 1.0 and 1.1 Basics 3 December 23rd, 2005 02:09 PM
aspnet user problem burdalescub Classic ASP Professional 4 December 14th, 2004 01:31 PM
Chap. 1 - Adding ASPNET User Account to Directory cjo BOOK: Beginning ASP.NET 1.0 2 October 15th, 2003 05:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.