Membership & Profiles

A

A_Republican

I have a CreateUserWizard object on my page with some additional fields:
First Name, Last Name, etc, etc.

I store all these additional fields in a profile for the user. The problem
is if I use Membership.DeleteUser(...) it will delete the user from the User
table, but it will not remove their profile. I'm not sure why this is
happening. Could someone explain what I'm doing wrong?

--
Regards,
Shaun Goldston

Liberalism is treason!
Vote Republican
 
S

Smartkid

(May be) this is the designed behavior of ASP.NET.
A quick (and dirty) workaround is to create a trigger in the 'users' table
or a delete cascade foreign key reference on the 'profile' table.
 
D

Dominick Baier

you are doing nothing wrong.

Just call ProfileManager.DeleteProfile in addition...
 
A

A_Republican

Okay maybe I just mis-understood the intelli-sense description.



--
Regards,
Shaun Goldston

Liberalism is treason!
Vote Republican
 
A

A_Republican

This is how I create a users profile:

Protected Sub CreateUserWizard_CreatedUser(ByVal sender As Object, ByVal e
As System.EventArgs) Handles CreateUserWizard.CreatedUser

ProfileBase.Create(Profile.UserName)

Profile.FirstName = CustomProfileInfo.FirstName
Profile.LastName = CustomProfileInfo.LastName
Profile.StreetAddress = CustomProfileInfo.StreetAddress
Profile.City = CustomProfileInfo.City
Profile.State = CustomProfileInfo.State
Profile.ZipCode = CustomProfileInfo.ZipCode
Profile.EmailAddress = CreateUserWizard.Email
Profile.HomePhoneNumber = CustomProfileInfo.HomePhoneNumber
Profile.CellPhoneNumber = CustomProfileInfo.CellPhoneNumber

End Sub


This is how I delete a user and their profile:

Private Function DeleteUser(ByVal strUserName As String) As Boolean
Dim blnResult As Boolean = False

'Delete the user and their profile
If blnResult = ProfileManager.DeleteProfile(strUserName) = True Then
If blnResult = Membership.DeleteUser(strUserName) = True Then
blnResult = True
End If
End If

Return blnResult
End Function


I have a GridView control that gets populated with every users profile
information. However, when I run my delete function for a user it doesn't get
deleted even though it says it was deleted. When I look in the database
(ASPNETDB) is still has their profile information and their membership
informatin.



This is off topic, but can someone tell me how to select the browser I want
to use from within VS 2005. Even though my default browser is IE, it always
opens FireFox.
 
A

A_Republican

1. If I start from an empty database, and add two users to the membership
database, why does the second users profile overwrite the first users profile?

2. Why when I call ProfileManager.DeleteProfile(strUserName) does it not
actually delete the profile?

3. Lastly, why does it not remove the entry from the database when I call
Membership.DeleteUser()?






This is how I create a users profile:

Protected Sub CreateUserWizard_CreatedUser(ByVal sender As Object, ByVal e
As System.EventArgs) Handles CreateUserWizard.CreatedUser

ProfileBase.Create(Profile.UserName)

Profile.FirstName = CustomProfileInfo.FirstName
Profile.LastName = CustomProfileInfo.LastName
Profile.StreetAddress = CustomProfileInfo.StreetAddress
Profile.City = CustomProfileInfo.City
Profile.State = CustomProfileInfo.State
Profile.ZipCode = CustomProfileInfo.ZipCode
Profile.EmailAddress = CreateUserWizard.Email
Profile.HomePhoneNumber = CustomProfileInfo.HomePhoneNumber
Profile.CellPhoneNumber = CustomProfileInfo.CellPhoneNumber

End Sub


This is how I delete a user and their profile:

Private Function DeleteUser(ByVal strUserName As String) As Boolean
Dim blnResult As Boolean = False

'Delete the user and their profile
If blnResult = ProfileManager.DeleteProfile(strUserName) = True Then
If blnResult = Membership.DeleteUser(strUserName) = True Then
blnResult = True
End If
End If

Return blnResult
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top