Question

When I use Membership.DeleteUser(userName, false) nothing happens. But When I use Membership.DeleteUser(userName, true) or Membership.DeleteUser(userName) error is thrown.

The DELETE statement conflicted with the REFERENCE constraint "FK__aspnet_Pr__UserI__3F115E1A".
The conflict occurred in database "MyDB", table "dbo.aspnet_Profile", column 'UserId'.

Here is my table key structures:

enter image description here

enter image description here

enter image description here

enter image description here

Can anybody help me out in solving this issue.?Not getting any idea.

Was it helpful?

Solution

Use ON DELETE CASCADE

it will specify whether you want rows deleted in a child table when corresponding rows are deleted in the parent table. If you do not specify cascading deletes, the default behavior of the database server prevents you from deleting data in a table if other tables reference it.

see http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.sqls.doc/sqls292.htm

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top