I have been banging my head over saving the Profile the whole day but couldn't accomplish it.
I am able to create a profile, delete, but not edit the details!After hustling with it for a while, after looking at the SQL Server Profiler logs, I understood I was indeed saving the details but somehow the same sproc is updating the record with previous details! Tried debugging but neither the page or master page's pageload event was hit!
Could it be a problem with db transaction? But my code has no transaction handling functionality, so I doubt if it has to do anything with rollback or stuff like that!
Here's my code, just in case if someone could find the bug!
web.config
<profile defaultProvider="CustSqlProfileProvider" enabled="true">
<providers>
<add name="CustSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="connString" applicationName="/save_online"/>
</providers>
<properties>
<add name="FirstName" type="System.String"/>
<add name="LastName" type="System.String"/>
<add name="Email" type="System.String"/>
<group name="Address">
<add name="Street" type="System.String"/>
<add name="City" type="System.String"/>
<add name="PostalCode" type="System.String"/>
</group>
<group name="Contact">
<add name="Phone" type="System.String"/>
<add name="Mobile" type="System.String"/>
</group>
<add name="ShoppingCart" type="psb.website.BLL.Store.ShoppingCart" serializeAs="Binary" allowAnonymous="true"/>
</properties>
</profile>
code
private void UpdateProfile()
{
ProfileCommon myprofile = this.Profile.GetProfile(HttpContext.Current.User.Identity.Name);
myprofile.FirstName = tbFirstName.Text.Trim();
myprofile.LastName = tbLastName.Text.Trim();
myprofile.Email = tbEmail.Text.Trim();
myprofile.Address.Street = tbStreetPhysical.Text.Trim();
myprofile.Address.City = tbCity.Text.Trim();
myprofile.Address.Posta开发者_如何学JAVAlCode = tbPostalCode.Text.Trim();
myprofile.Contact.Phone = tbPhone1.Text.Trim();
myprofile.Contact.Mobile = tbMobile.Text.Trim();
myprofile.Save();
}
In SQL Profiler trace
exec dbo.aspnet_Profile_SetProperties is executed with right values when ProfileCommon's save() is called and after the page is done loading, the same st.procedure is executed again with previous values. How is it called second time?! This is so annoying!!
Would this data from SQL Server Profiler help?
-- network protocol: LPC
set quoted_identifier on
set arithabort off
set numeric_roundabort off
set ansi_warnings on
set ansi_padding on
set ansi_nulls on
set concat_null_yields_null on
set cursor_close_on_commit off
set implicit_transactions off
set language us_english
set dateformat mdy
set datefirst 7
set transaction isolation level read committed
More info: Admin is able to update profile information of other users but not able update his own profile. And other web site users are also unable to update their profile info!
How strange!
Someone please bail me out!
This seems to be a duplicate of your other profile save question. Regardless, you do not need to call Save at the end. This automatically happens if you have the auto save feature turned on in the config. If you want to explicitly call Save, just turn that setting off and things should work like you expect.
Similar to this question.
精彩评论