Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > BOOK: Beginning ASP.NET 2.0 and Databases
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 23rd, 2008, 12:18 PM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
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
  #2 (permalink)  
Old December 23rd, 2008, 12:29 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 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!
  #3 (permalink)  
Old December 23rd, 2008, 06:54 PM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
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
  #4 (permalink)  
Old December 25th, 2008, 05:15 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:03 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.