This error is usually due to the aspnet_ membership tables being out of sync with the DotNetNuke Users table.
Here's a way to go about deleting those orphaned Users from the aspnet_* memberRole tables
There are a lot of Referential Integrity constraints on the aspnet_ membership tables that makes it kind of difficult to delete them directly.
This SQL will loop through them all and delete any that are not in the DNN Users table:
DECLARE @UserName varchar (50)--get a cursor to hold all the orphaned users--that are in aspnet_Users table that are not in the DNN Users tableDECLARE users_cursor CURSOR FORSELECT au.UserName FROM aspnet_Users au LEFT OUTER JOIN Users u on au.UserName = U.UserName WHERE U.UserName is nullOPEN users_cursor-- Perform the first fetch.FETCH NEXT FROM users_cursor INTO @UserName-- Check @@FETCH_STATUS to see if there are any more rows to fetch.WHILE @@FETCH_STATUS = 0BEGIN--delete the user from all the aspnet_* tables that it may be in--one at a time to avoid referrential integrity constraintsdelete aspnet_Membership where UserId = (select am.UserId from aspnet_Membership am inner join aspnet_Users au on am.UserId = au.UserIdwhere au.Username =@UserName)delete aspnet_Profile where UserId = (select ap.UserId from aspnet_Profile ap inner join aspnet_Users au on ap.UserId = au.UserIdwhere au.Username =@UserName)delete aspnet_UsersInRoles where UserId in (select uir.UserId from aspnet_UsersInRoles uir inner join aspnet_Users au on uir.UserId = au.UserIdwhere au.Username =@UserName)delete from aspnet_Users where Username =@UserName FETCH NEXT FROM users_cursor INTO @UserNameENDCLOSE users_cursorDEALLOCATE users_cursorGO
Remember Me