This is a portion of my Web.config file:
<system.web>
<membership defaultProvider ="SqlProvide r">
<providers>
<clear/>
<add name="SqlProvid er"
type="System.We b.Security.SqlM embershipProvid er"
connectionStrin gName="SqlServi ces"
applicationName ="CollegeRepubl icans"
minRequiredPass wordLength="8"
minRequiredNona lphanumericChar acters="0"
enablePasswordR etrieval="true"
enablePasswordR eset="true"
passwordFormat= "Encrypted"
requiresQuestio nAndAnswer="tru e" />
</providers>
</membership>
<profile defaultProvider ="SqlProvide r">
<providers>
<add name="SqlProvid er"
type="System.We b.Profile.SqlPr ofileProvider"
connectionStrin gName="SqlServi ces" />
</providers>
<properties>
<add name="UserName" defaultValue="" allowAnonymous= "true" />
<add name="FirstName " defaultValue="" allowAnonymous= "true" />
<add name="LastName" defaultValue="" allowAnonymous= "true" />
<add name="StreetAdd ress" defaultValue="" allowAnonymous= "true" />
<add name="City" defaultValue="" allowAnonymous= "true" />
<add name="State" defaultValue="" allowAnonymous= "true" />
<add name="ZipCode" defaultValue="" allowAnonymous= "true" />
<add name="EmailAddr ess" defaultValue="" allowAnonymous= "true" />
<add name="HomePhone Number" defaultValue="" allowAnonymous= "true" />
<add name="CellPhone Number" defaultValue="" allowAnonymous= "true" />
<add name="Volunteer " defaultValue="" allowAnonymous= "true" />
</properties>
</profile>
</system.web>
This is how I create a new user and profile:
Try
'Create the profile
ProfileBase.Cre ate(CreateUserW izard.UserName)
'Gather profile information
Profile.UserNam e = CleanString(Cre ateUserWizard.U serName)
Profile.FirstNa me = CleanString(Cus tomProfileInfo. FirstName)
Profile.LastNam e = CleanString(Cus tomProfileInfo. LastName)
Profile.StreetA ddress =
CleanString(Cus tomProfileInfo. StreetAddress)
Profile.City = CleanString(Cus tomProfileInfo. City)
Profile.State = CleanString(Cus tomProfileInfo. State)
Profile.ZipCode = CleanString(Cus tomProfileInfo. ZipCode)
Profile.EmailAd dress = CreateUserWizar d.Email
Profile.HomePho neNumber =
CleanString(Cus tomProfileInfo. HomePhoneNumber )
Profile.CellPho neNumber =
CleanString(Cus tomProfileInfo. CellPhoneNumber )
Profile.Volunte er = CleanString(Cus tomProfileInfo. Volunteer)
'Default each new user to the role of USER
Roles.AddUserTo Role(CreateUser Wizard.UserName , "User")
Catch strError As Exception
'WriteLog(strEr ror.Message)
End Try
This is how I delete a user:
Private Function DeleteUser(ByVa l strUserName As String) As Boolean
Dim blnResult As Boolean = False
Try
'Delete the users profile
If blnResult = ProfileManager. DeleteProfile(s trUserName) = True
Then
'Delete the users membership
If blnResult = Membership.Dele teUser(strUserN ame) = True Then
blnResult = True
End If
End If
Catch strError As Exception
'WriteLog(strEr ror.Message)
End Try
Return blnResult
End Function
There are many problems I am having;
1. When adding a new user sometimes there profile information doesn't get
added
2. When adding a new user sometimes they don't get added to the membership
3. When adding a new user sometimes they over write existing profile
information to current users.
4. When updating a current users profile it creates duplicate profile records
5. When displaying all the user in a GridView using the GetAllUsers method
it doesn't always display every user, if at all.
6. Deleting users does not work, nor does it delete their profile.
Can anyone help?
Thanks
<system.web>
<membership defaultProvider ="SqlProvide r">
<providers>
<clear/>
<add name="SqlProvid er"
type="System.We b.Security.SqlM embershipProvid er"
connectionStrin gName="SqlServi ces"
applicationName ="CollegeRepubl icans"
minRequiredPass wordLength="8"
minRequiredNona lphanumericChar acters="0"
enablePasswordR etrieval="true"
enablePasswordR eset="true"
passwordFormat= "Encrypted"
requiresQuestio nAndAnswer="tru e" />
</providers>
</membership>
<profile defaultProvider ="SqlProvide r">
<providers>
<add name="SqlProvid er"
type="System.We b.Profile.SqlPr ofileProvider"
connectionStrin gName="SqlServi ces" />
</providers>
<properties>
<add name="UserName" defaultValue="" allowAnonymous= "true" />
<add name="FirstName " defaultValue="" allowAnonymous= "true" />
<add name="LastName" defaultValue="" allowAnonymous= "true" />
<add name="StreetAdd ress" defaultValue="" allowAnonymous= "true" />
<add name="City" defaultValue="" allowAnonymous= "true" />
<add name="State" defaultValue="" allowAnonymous= "true" />
<add name="ZipCode" defaultValue="" allowAnonymous= "true" />
<add name="EmailAddr ess" defaultValue="" allowAnonymous= "true" />
<add name="HomePhone Number" defaultValue="" allowAnonymous= "true" />
<add name="CellPhone Number" defaultValue="" allowAnonymous= "true" />
<add name="Volunteer " defaultValue="" allowAnonymous= "true" />
</properties>
</profile>
</system.web>
This is how I create a new user and profile:
Try
'Create the profile
ProfileBase.Cre ate(CreateUserW izard.UserName)
'Gather profile information
Profile.UserNam e = CleanString(Cre ateUserWizard.U serName)
Profile.FirstNa me = CleanString(Cus tomProfileInfo. FirstName)
Profile.LastNam e = CleanString(Cus tomProfileInfo. LastName)
Profile.StreetA ddress =
CleanString(Cus tomProfileInfo. StreetAddress)
Profile.City = CleanString(Cus tomProfileInfo. City)
Profile.State = CleanString(Cus tomProfileInfo. State)
Profile.ZipCode = CleanString(Cus tomProfileInfo. ZipCode)
Profile.EmailAd dress = CreateUserWizar d.Email
Profile.HomePho neNumber =
CleanString(Cus tomProfileInfo. HomePhoneNumber )
Profile.CellPho neNumber =
CleanString(Cus tomProfileInfo. CellPhoneNumber )
Profile.Volunte er = CleanString(Cus tomProfileInfo. Volunteer)
'Default each new user to the role of USER
Roles.AddUserTo Role(CreateUser Wizard.UserName , "User")
Catch strError As Exception
'WriteLog(strEr ror.Message)
End Try
This is how I delete a user:
Private Function DeleteUser(ByVa l strUserName As String) As Boolean
Dim blnResult As Boolean = False
Try
'Delete the users profile
If blnResult = ProfileManager. DeleteProfile(s trUserName) = True
Then
'Delete the users membership
If blnResult = Membership.Dele teUser(strUserN ame) = True Then
blnResult = True
End If
End If
Catch strError As Exception
'WriteLog(strEr ror.Message)
End Try
Return blnResult
End Function
There are many problems I am having;
1. When adding a new user sometimes there profile information doesn't get
added
2. When adding a new user sometimes they don't get added to the membership
3. When adding a new user sometimes they over write existing profile
information to current users.
4. When updating a current users profile it creates duplicate profile records
5. When displaying all the user in a GridView using the GetAllUsers method
it doesn't always display every user, if at all.
6. Deleting users does not work, nor does it delete their profile.
Can anyone help?
Thanks