Foreign key 'FK_DNN_LE_wns_lightbox_moduleid' references invalid table 'dbo.Modules'.

Sep 29, 2009 at 7:04 AM

Running DNN 5.1.2.     Trying to install LightboxGallery 1.0.4 (no previous installation) I get the following error:


Info Executing 01.00.00.SqlDataProvider
Info Start Sql execution: 01.00.00.SqlDataProvider file
Failure SQL Execution resulted in following Exceptions: System.Data.SqlClient.SqlException: Foreign key 'FK_DNN_LE_wns_lightbox_moduleid' references invalid table 'dbo.Modules'. Could not create constraint. See previous errors. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at DotNetNuke.Data.SqlDataProvider.ExecuteADOScript(String SQL) at DotNetNuke.Data.SqlDataProvider.ExecuteScript(String Script, Boolean UseTransactions) ALTER TABLE dbo.[DNN_LE_wns_lightbox] WITH NOCHECK ADD CONSTRAINT [FK_DNN_LE_wns_lightbox_moduleid] FOREIGN KEY ([ModuleId]) REFERENCES dbo.[Modules] ([ModuleId]) ON DELETE CASCADE NOT FOR REPLICATION
Info End Sql execution: 01.00.00.SqlDataProvider file
Oct 22, 2009 at 4:35 PM

This can easily be fixed. Just unzip the installation file, and find the file 01.00.00.SqlDataProvider located in the directory Providers/DataProviders/SqlDataProvider. Open this file using notepad (or any text editor that may read and write UTF-8 encoded files) and search for these lines:

ALTER TABLE {databaseOwner}[{objectQualifier}wns_lightbox] WITH NOCHECK
 ADD CONSTRAINT [FK_{objectQualifier}wns_lightbox_moduleid] FOREIGN KEY ([ModuleId])

Change the third line to:

 REFERENCES {databaseOwner}[{objectQualifier}Modules] ([ModuleId]) ON DELETE CASCADE NOT FOR REPLICATION

Re-zip the installation file. the installation works fine then.

Best wishes

Will: Please correct that error in your next release. No one who uses object qualifiers can install your module. And: Use an object qualifier on your developing system, then things like this cannot happen...

Nov 18, 2009 at 9:33 PM

Sorry guys... I was not subscribed to the discussions, even though I thought I was. :(

See this issue: