G
Guest
When using the Web Site Administration Tool, I get the following error when
trying to delete a user in a web application I configured to use membership,
roles, and profiles:
"An error was encountered. Please return to the previous page and try again.
The following message may help in diagnosing the problem: The DELETE
statement conflicted with the REFERENCE constraint
"FK__aspnet_Me__UserI__24285DB4". The conflict occurred in database
"GalleryServerPro2", table "dbo.aspnet_Membership", column 'UserId'. The
statement has been terminated. at
System.Web.Administration.WebAdminPage.CallWebAdminHelperMethod(Boolean
isMembership, String methodName, Object[] parameters, Type[] paramTypes) at
ASP.security_users_manageusers_aspx.Yes_Click(Object sender, EventArgs e) at
System.Web.UI.WebControls.Button.OnClick(EventArgs e) at
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) at
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint)"
The data store is SQL Server 2005, and this is all on my development PC.
Ultimately, the problem can be traced to the following line in the stored
procedure aspnet_Users_DeleteUser:
IF ((@TablesToDeleteFrom & 1) <> 0 AND
(EXISTS (SELECT name FROM sysobjects WHERE (name =
N'vw_aspnet_MembershipUsers') AND (type = 'V'))))
For some reason, the "SELECT from sysobjects..." is not finding a match,
causing the condition to fail, which means the following line does not
execute:.
DELETE FROM dbo.aspnet_Membership WHERE @UserId = UserId
Because this does not execute, the following subsequent SQL fails with the
constraint violation I listed at the beginning:
DELETE FROM dbo.aspnet_Users WHERE @UserId = UserId
The "SELECT name FROM sysobjects..." should return a match. In fact, it does
when I execute the query manually in a query window ("SELECT name FROM
sysobjects WHERE (name = N'vw_aspnet_MembershipUsers') AND (type = 'V')"
returns 1 record).
It boils down to this: The stored procedure is behaving as stated when using
the Web Site Administration Tool or calling Membership.DeleteUser() from an
ASPX page. However, when I step through the proc manually, using right-click
"Step Into Stored Procedure" in VS 2005, and giving it the same initial
parameter values, it works correctly! That is, the "SELECT name FROM
sysobjects..." query does not find a match using WSAT or DeleteUser(), but it
does find a match when executing the proc manually.
How can it be that the proc behaves differently depending on who calls it?
As best I can tell, the parameters are exactly the same. More importantly,
what do I need to do so that the Web Site Tool and the DeleteUser() function
works?
Another user reported the issue but without resolving it:
http://groups.google.com/group/micr...MembershipUsers&rnum=5&hl=en#51d8f7776077ffe0
Thanks for any help!
Roger Martin
www.galleryserverpro.com
www.techinfosystems.com
trying to delete a user in a web application I configured to use membership,
roles, and profiles:
"An error was encountered. Please return to the previous page and try again.
The following message may help in diagnosing the problem: The DELETE
statement conflicted with the REFERENCE constraint
"FK__aspnet_Me__UserI__24285DB4". The conflict occurred in database
"GalleryServerPro2", table "dbo.aspnet_Membership", column 'UserId'. The
statement has been terminated. at
System.Web.Administration.WebAdminPage.CallWebAdminHelperMethod(Boolean
isMembership, String methodName, Object[] parameters, Type[] paramTypes) at
ASP.security_users_manageusers_aspx.Yes_Click(Object sender, EventArgs e) at
System.Web.UI.WebControls.Button.OnClick(EventArgs e) at
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) at
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint)"
The data store is SQL Server 2005, and this is all on my development PC.
Ultimately, the problem can be traced to the following line in the stored
procedure aspnet_Users_DeleteUser:
IF ((@TablesToDeleteFrom & 1) <> 0 AND
(EXISTS (SELECT name FROM sysobjects WHERE (name =
N'vw_aspnet_MembershipUsers') AND (type = 'V'))))
For some reason, the "SELECT from sysobjects..." is not finding a match,
causing the condition to fail, which means the following line does not
execute:.
DELETE FROM dbo.aspnet_Membership WHERE @UserId = UserId
Because this does not execute, the following subsequent SQL fails with the
constraint violation I listed at the beginning:
DELETE FROM dbo.aspnet_Users WHERE @UserId = UserId
The "SELECT name FROM sysobjects..." should return a match. In fact, it does
when I execute the query manually in a query window ("SELECT name FROM
sysobjects WHERE (name = N'vw_aspnet_MembershipUsers') AND (type = 'V')"
returns 1 record).
It boils down to this: The stored procedure is behaving as stated when using
the Web Site Administration Tool or calling Membership.DeleteUser() from an
ASPX page. However, when I step through the proc manually, using right-click
"Step Into Stored Procedure" in VS 2005, and giving it the same initial
parameter values, it works correctly! That is, the "SELECT name FROM
sysobjects..." query does not find a match using WSAT or DeleteUser(), but it
does find a match when executing the proc manually.
How can it be that the proc behaves differently depending on who calls it?
As best I can tell, the parameters are exactly the same. More importantly,
what do I need to do so that the Web Site Tool and the DeleteUser() function
works?
Another user reported the issue but without resolving it:
http://groups.google.com/group/micr...MembershipUsers&rnum=5&hl=en#51d8f7776077ffe0
Thanks for any help!
Roger Martin
www.galleryserverpro.com
www.techinfosystems.com