Constraint Error in DNN

Oct 24, 2015 at 7:05 PM
Running dnn 7.4.2 ran version I of TurboScripts and have this constraint error for Active Forums

System.Data.SqlClient.SqlException (0x80131904): The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_activeforums_ForumTopics_activeforums_Replies". The conflict occurred in database "423345_rheebo_2008", table "dbo.activeforums_Replies", column 'ReplyId'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource
1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at DotNetNuke.Data.SqlDataProvider.ExecuteScriptInternal(String connectionString, String script)
ClientConnectionId:e63e5a00-194c-4733-b196-54e227fb5493

-- drop AF foregn keys with known issues:
IF EXISTS (SELECT * FROM Sys.Foreign_Keys WHERE Parent_Object_id = OBJECT_ID(N'dbo.[activeforums_ForumTopics]')
                         AND name = N'FK_Journal_Data_activeforums_ForumTopics_activeforums_Replies')
ALTER TABLE dbo.[activeforums_ForumTopics] 
 DROP CONSTRAINT [FK_activeforums_ForumTopics_activeforums_Replies]
-- make sure, all constraints are enabled
EXEC sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"
Coordinator
Oct 27, 2015 at 9:09 AM
Thanks, I'll have a look. I noticed on a longtime DNN that Active Forum has a couple of non-enforced FK constraints, this one caused issues, due to FK violations
Coordinator
Oct 27, 2015 at 4:05 PM
fixed in revision m
Marked as answer by leupold on 10/27/2015 at 9:05 AM