Cannot delete user with Web Site Administration Tool

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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/microsoft.public.sqlserver.programming/browse_thread/thread/2f35a7548cbe94ce/51d8f7776077ffe0?lnk=st&q=vw_aspnet_MembershipUsers&rnum=5&hl=en#51d8f7776077ffe0

Thanks for any help!
Roger Martin
www.galleryserverpro.com
www.techinfosystems.com


.



Relevant Pages

  • FormView InsertingItem - Checking before insert not working
    ... I have a formview called fv1. ... UserWebSiteTextBox.Text and do a lookup and return the Userid if thier ... Plese enter the web site you would like. ... Dim UserID As Integer ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Select several words
    ... .Execute findText:=oldPart, _ ... Word MVP web site http://word.mvps.org ... Dim ChangeDoc As Document, RefDoc As Document ...
    (microsoft.public.word.docmanagement)
  • ASPNETDB Problem - Unable to connect to SQL Server database
    ... a web site I'm creating using VS 2005 C#. ... "Unable to connect to SQL Server database". ... Site Administration Tool and got the same error. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: using membership providers for a web application
    ... The Web Site Administration Tool persists settings in the web.config file. ... I am trying to figure out how to use asp.net membership providers for my ... is it possible to use membership providers with a web project? ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: HELP! Windows authentication gives wrong user name
    ... public static string UserID() ... When someone accesses the web site, a logon dialog box shows up. ...
    (microsoft.public.dotnet.security)