0

每当我尝试使用或不使用 WebMatrix 安装 DNN7 时,都会遇到相同的错误。我认为尝试了所有解决方案 - 为文件夹提供了适当的权限,使用了真正的排序规则。但不工作。每当我安装时,我都会收到此错误。

安装日志:10/10/2013 14:01:59 [错误] DotNetNuke.Services.Upgrade.Upgrade System.Data.SqlClient.SqlException (0x80131904): 必须声明标量变量“@portalid”。

    0:00 Minutes   |   15% ERROR occured - System.Data.SqlClient.SqlException (0x80131904): Must declare the scalar variable "@portalid".
 Incorrect syntax near the keyword 'ELSE'.
 at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
 at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 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)
 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:fe779643-472b-4661-b22d-a75502ab64d5

 CREATE procedure dbo.GetTabPermissionsByPortal

 @PortalID int

 AS

 IF @portalid is not null
 BEGIN 
 SELECT *
 FROM dbo.vw_TabPermissions
 WHERE PortalID = @PortalID
 END
 ELSE
 BEGIN
 SELECT *
 FROM dbo.vw_TabPermissions
 WHERE PortalID IS NULL 
 END

 System.Data.SqlClient.SqlException (0x80131904): Must declare the scalar variable "@id".
 at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
 at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 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)
 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:f7736e34-4553-4d9c-8015-0a3af78a264e

 CREATE PROCEDURE dbo.[Mobile_DeleteRedirection] @Id INT
 AS 
 DELETE FROM dbo.Mobile_RedirectionRules
 WHERE RedirectionId = @id

 DELETE FROM dbo.Mobile_Redirections
 WHERE Id = @Id

 System.Data.SqlClient.SqlException (0x80131904): Must declare the scalar variable "@id".
 at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
 at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 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)
 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:4c1cb73e-36c9-4171-8582-5ffa8f1d125a

 CREATE PROCEDURE dbo.[Mobile_DeleteRedirectionRule] @Id INT
 AS 
 DELETE FROM dbo.Mobile_RedirectionRules
 WHERE Id = @id

 System.Data.SqlClient.SqlException (0x80131904): Must declare the scalar variable "@id".
 Must declare the scalar variable "@id".
 Must declare the scalar variable "@id".
 at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
 at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 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)
 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:4b5c9a84-e3d8-494f-a319-f0330c949867

 CREATE PROCEDURE dbo.[AddSearchItemWord]
 @SearchItemID INT,
 @SearchWordsID INT,
 @Occurrences INT
 AS
 DECLARE @ID INT
 SELECT @id = SearchItemWordId
 FROM dbo.SearchItemWord
 WHERE SearchItemId = @SearchItemID
 AND SearchWordsId = @SearchWordsID
 IF @ID IS NULL
 BEGIN
 INSERT INTO dbo.SearchItemWord
 ([SearchItemId],
 [SearchWordsId],
 [Occurrences])
 VALUES (@SearchItemID,
 @SearchWordsID,
 @Occurrences)
 SELECT Scope_identity()
 END
 ELSE
 BEGIN
 UPDATE dbo.SearchItemWord
 SET Occurrences = @Occurrences
 WHERE SearchItemWordId = @id
 AND Occurrences <> @Occurrences
 SELECT @id
 END

 System.Data.SqlClient.SqlException (0x80131904): Must declare the scalar variable "@AdminTabid".
 at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
 at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 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)
 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:a1e87e80-721e-4d05-80be-11963750f144

 CREATE PROCEDURE dbo.[UpdatePortalInfo]
 @PortalID   int,
 @PortalGroupID  int,
 @PortalName     nvarchar(128),
 @LogoFile   nvarchar(50),
 @FooterText nvarchar(100),
 @ExpiryDate     datetime,
 @UserRegistration   int,
 @BannerAdvertising  int,
 @Currency   char(3),
 @AdministratorId    int,
 @HostFee    money,
 @HostSpace  int,
 @PageQuota  int,
 @UserQuota  int,
 @PaymentProcessor   nvarchar(50),
 @ProcessorUserId    nvarchar(50),
 @ProcessorPassword  nvarchar(50),
 @Description    nvarchar(500),
 @KeyWords   nvarchar(500),
 @BackgroundFile     nvarchar(50),
 @SiteLogHistory     int,
 @SplashTabId    int,
 @HomeTabId  int,
 @LoginTabId     int,
 @RegisterTabId  int,
 @UserTabId  int,
 @SearchTabId    int,
 @DefaultLanguage    nvarchar(10),
 @HomeDirectory  varchar(100),
 @LastModifiedByUserID  int,
 @CultureCode nvarchar(50)

 AS

 UPDATE dbo.Portals
 SET 
 PortalGroupID   = @PortalGroupID,
 ExpiryDate  = @ExpiryDate,
 UserRegistration    = @UserRegistration,
 BannerAdvertising  = @BannerAdvertising,
 Currency    = @Currency,
 AdministratorId     = @AdministratorId,
 HostFee     = @HostFee,
 HostSpace   = @HostSpace,
 PageQuota   = @PageQuota,
 UserQuota   = @UserQuota,
 PaymentProcessor    = @PaymentProcessor,
 ProcessorUserId     = @ProcessorUserId,
 ProcessorPassword  = @ProcessorPassword,
 SiteLogHistory  = @SiteLogHistory,
 DefaultLanguage     = @DefaultLanguage,
 HomeDirectory   = @HomeDirectory,
 LastModifiedByUserID = @LastModifiedByUserID,
 LastModifiedOnDate = getdate()
 WHERE PortalId = @PortalID

 IF EXISTS (SELECT * FROM dbo.PortalLocalization WHERE PortalId = @PortalID AND CultureCode = @CultureCode)
 BEGIN 
 UPDATE dbo.PortalLocalization
 SET
 PortalName  = @PortalName,
 LogoFile    = @LogoFile,
 FooterText  = @FooterText,
 Description     = @Description,
 KeyWords    = @KeyWords,
 BackgroundFile  = @BackgroundFile,
 HomeTabId   = @HomeTabId,
 LoginTabId  = @LoginTabId,
 RegisterTabId   = @RegisterTabId,
 UserTabId   = @UserTabId,
 SplashTabId     = @SplashTabId,
 SearchTabId     = @SearchTabId,
 LastModifiedByUserID   = @LastModifiedByUserID,
 LastModifiedOnDate  = getdate()
 WHERE  PortalId = @PortalID 
 AND CultureCode = @CultureCode
 END 
 ELSE
 BEGIN 
 DECLARE @AdminTabId int
 SET @AdminTabId = (SELECT AdminTabId 
 FROM dbo.PortalLocalization 
 WHERE PortalID = @PortalID AND CultureCode='en-US')

 INSERT INTO dbo.PortalLocalization (
 [PortalID],
 [CultureCode],
 [PortalName],
 [LogoFile],
 [FooterText],
 [Description],
 [KeyWords],
 [BackgroundFile],
 [HomeTabId],
 [LoginTabId],
 [UserTabId],
 [AdminTabId],
 [SplashTabId],
 [SearchTabId],
 [CreatedByUserID],
 [CreatedOnDate],
 [LastModifiedByUserID],
 [LastModifiedOnDate]
 )
 VALUES (
 @PortalID,
 @CultureCode,
 @PortalName,
 @LogoFile, 
 @FooterText,
 @Description,
 @KeyWords,
 @BackgroundFile,
 @HomeTabId ,
 @LoginTabId ,
 @UserTabId,
 @AdminTabid,
 @SplashTabId ,
 @SearchTabId,
 -1,
 getdate(),
 -1,
 getdate()
 )
 END

 System.Data.SqlClient.SqlException (0x80131904): XQuery: Unable to resolve sql:variable('@userid'). The variable must be declared as a scalar TSQL variable.
 at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
 at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 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)
 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:3f38397d-5727-4ab3-9f44-fa70cbc30d82

 CREATE PROCEDURE dbo.[Journal_Comment_Like]
 @JournalId int,
 @CommentId int,
 @UserId int,
 @UserName nvarchar(50)
 AS
 DECLARE @cxml xml
 SET @cxml = (SELECT CommentXML FROM dbo.[Journal_Comment] WHERE CommentId = @CommentId AND JournalId = @JournalId)
 IF @cxml IS NULL 
 BEGIN
 DECLARE @x xml
 SET @x = '<root></root>';
 UPDATE dbo.[Journal_Comments] 
 SET CommentXML = @x
 WHERE JournalId = @JournalId AND CommentId = @CommentId
 END
 IF EXISTS(SELECT CommentId
 FROM dbo.[Journal_Comments] 
 WHERE JournalId = @JournalId AND CommentId = @CommentId
 AND 
 CommentXML.exist('/root/likes/u[@uid=sql:variable("@userid")]') = 1)
 BEGIN
 UPDATE dbo.[Journal_Comments]
 SET CommentXML.modify('delete (/root/likes/u[@uid=sql:variable("@UserId")])')
 WHERE JournalId = @JournalId AND CommentId = @CommentId
 AND journalxml.exist('/root/likes/u[@uid=sql:variable("@UserId")]') = 1
 END
 ELSE
 BEGIN
 BEGIN
 IF NOT EXISTS(SELECT CommentId FROM dbo.[Journal_Comments]
 WHERE JournalId = @JournalId AND CommentId = @CommentID
 AND
 CommentXML.exist('/root/likes') = 1)
 BEGIN
 UPDATE dbo.[Journal_Comments]
 SET CommentXML.modify('insert <likes /> as last into (/root)[1]') 
 WHERE JournalId = @JournalId AND CommentId = @CommentId AND CommentXML.exist('/root') = 1

 END
 END
 BEGIN
 UPDATE dbo.[Journal_Comments]
 SET CommentXML.modify('insert <u uid="{xs:string(sql:variable("@UserId"))}" un="{xs:string(sql:variable("@UserName"))}" /> as last into (/root/likes)[1]')
 Where JournalId = @JournalId AND CommentId = @CommentId AND CommentXML.exist('/root/likes') = 1

 END
 END

 System.Data.SqlClient.SqlException (0x80131904): XQuery: Unable to resolve sql:variable('@userid'). The variable must be declared as a scalar TSQL variable.
 at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
 at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 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)
 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:a1e87e80-721e-4d05-80be-11963750f144

 CREATE PROCEDURE dbo.[Journal_Like]
 @JournalId int,
 @UserId int,
 @UserName nvarchar(50)
 AS 
 IF NOT EXISTS (SELECT JournalId from dbo.[Journal_Data] WHERE JournalId = @JournalId)
 BEGIN
 DECLARE @x xml
 SET @x = '<items><item /></items>';
 INSERT INTO dbo.[Journal_Data] 
 (JournalId, JournalXML)
 VALUES
 (@JournalId, @x)
 END
 IF EXISTS(SELECT j.JournalId 
 FROM dbo.Journal as j INNER JOIN
 dbo.Journal_Data as jx ON j.JournalId = jx.JournalId 
 WHERE j.JournalId = @JournalId 
 AND 
 jx.journalxml.exist('/items/likes/u[@uid=sql:variable("@userid")]') = 1)
 BEGIN
 UPDATE dbo.Journal_Data
 SET JournalXML.modify('delete (/items/likes/u[@uid=sql:variable("@UserId")])')
 WHERE JournalId = @JournalId 
 AND journalxml.exist('/items/likes/u[@uid=sql:variable("@UserId")]') = 1
 END
 ELSE
 BEGIN
 BEGIN
 IF NOT EXISTS(SELECT JournalId FROM dbo.Journal_Data
 WHERE JournalId = @JournalId 
 AND
 journalxml.exist('/items/likes') = 1)
 BEGIN
 UPDATE dbo.Journal_Data
 SET JournalXML.modify('insert <likes /> as last into (/items)[1]') 
 WHERE JournalId = @JournalId AND journalxml.exist('/items') = 1
 END
 END
 BEGIN
 UPDATE dbo.Journal_Data
 SET JournalXML.modify('insert <u uid="{xs:string(sql:variable("@UserId"))}" un="{xs:string(sql:variable("@UserName"))}" /> as last into (/items/likes)[1]')
 Where JournalId = @JournalId AND journalxml.exist('/items/likes') = 1
 END
 END

 System.Data.SqlClient.SqlException (0x80131904): Invalid column name 'JournalId'.
 at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
 at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 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)
 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:4b5c9a84-e3d8-494f-a319-f0330c949867

 CREATE PROCEDURE dbo.[Journal_ListForGroup]
 @PortalId int,
 @ModuleId int,
 @CurrentUserId int,
 @GroupId int,
 @RowIndex int,
 @MaxRows int
 AS
 DECLARE @EndRow int
 SET @EndRow = @RowIndex + @MaxRows;

 DECLARE @j TABLE(id int IDENTITY, journalid int, datecreated datetime)
 IF EXISTS(SELECT * from dbo.[Journal_TypeFilters] WHERE ModuleId = @ModuleId)
 INSERT INTO @j 
 SELECT j.journalid, jt.datecreated from (
 SELECT DISTINCT js.JournalId from dbo.[Journal] as j
 INNER JOIN dbo.[Journal_Security] as js ON js.JournalId = j.JournalId
 INNER JOIN dbo.[Journal_User_Permissions](@PortalId,@CurrentUserId ,1) as t 
 ON t.seckey = js.SecurityKey AND (js.SecurityKey = 'R' + CAST(@GroupId as nvarchar(100)) OR js.SecurityKey = 'E')
 WHERE j.PortalId = @PortalId
 ) as j INNER JOIN dbo.[Journal] jt ON jt.JournalId = j.JournalId AND jt.PortalId = @PortalId AND jt.GroupId = @GroupId
 INNER JOIN dbo.[Journal_TypeFilters] as jf ON jf.JournalTypeId = jt.JournalTypeId AND jf.ModuleId = @ModuleId
 ORDER BY jt.DateCreated DESC, jt.JournalId DESC;
 ELSE
 INSERT INTO @j 
 SELECT j.journalid, jt.datecreated from (
 SELECT DISTINCT js.JournalId from dbo.[Journal] as j
 INNER JOIN dbo.[Journal_Security] as js ON js.JournalId = j.JournalId
 INNER JOIN dbo.[Journal_User_Permissions](@PortalId,@CurrentUserId ,1) as t 
 ON t.seckey = js.SecurityKey AND (js.SecurityKey = 'R' + CAST(@GroupId as nvarchar(100)) OR js.SecurityKey = 'E')
 WHERE j.PortalId = @PortalId
 ) as j INNER JOIN dbo.[Journal] jt ON jt.JournalId = j.JournalId AND jt.PortalId = @PortalId AND jt.GroupId = @GroupId
 ORDER BY jt.DateCreated DESC, jt.JournalId DESC;


 WITH journalItems AS
 (
 SELECT j.JournalId,
 ROW_NUMBER() OVER (ORDER BY j.JournalId DESC) AS RowNumber
 FROM   dbo.[Journal] as j INNER JOIN @j as jtmp ON jtmp.JournalId = j.JournalId
 WHERE j.PortalId = @PortalId
 )
 SELECT j.JournalId, j.JournalTypeId, j.Title, j.Summary, j.UserId, j.DateCreated, j.DateUpdated, j.PortalId,
 j.ProfileId, j.GroupId, j.ObjectKey, j.AccessKey,
 "JournalOwner" = '<entity><id>' + CAST(r.RoleId as nvarchar(150)) + '</id><name><![CDATA[' + r.RoleName + ']]></name></entity>',
 "JournalAuthor" = CASE WHEN ISNULL(a.UserId,-1) >0 THEN '<entity><id>' + CAST(a.UserId as nvarchar(150)) + '</id><name><![CDATA[' + a.DisplayName + ']]></name></entity>' ELSE '' END,
 "JournalOwnerId" = ISNULL(j.ProfileId,j.UserId),
 jt.Icon, jt.JournalType,
 "Profile" = CASE WHEN j.ProfileId > 0 THEN '<entity><id>' + CAST(p.UserID as nvarchar(150)) + '</id><name><![CDATA[' + p.DisplayName + ']]></name><vanity></vanity></entity>' ELSE '' END,
 jd.JournalXML, j.ContentItemId, j.ItemData, RowNumber
 FROM journalItems as ji INNER JOIN 
 dbo.[Journal] as j ON j.JournalId = ji.JournalId INNER JOIN
 dbo.[Journal_Types] as jt ON jt.JournalTypeId = j.JournalTypeId INNER JOIN
 dbo.[Roles] as r ON j.GroupId = r.RoleId LEFT OUTER JOIN
 dbo.[Journal_Data] as jd on jd.JournalId = j.JournalId LEFT OUTER JOIN
 dbo.[Users] AS p ON j.ProfileId = p.UserID LEFT OUTER JOIN
 dbo.[Users] AS a ON j.UserId = a.UserID
 WHERE  RowNumber BETWEEN @RowIndex AND @EndRow
 ORDER BY RowNumber ASC;

 System.Data.SqlClient.SqlException (0x80131904): Invalid column name 'JournalId'.
 at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
 at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 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)
 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:4c1cb73e-36c9-4171-8582-5ffa8f1d125a

 CREATE PROCEDURE dbo.[Journal_ListForSummary]
 @PortalId int,
 @ModuleId int,
 @CurrentUserId int,
 @RowIndex int,
 @MaxRows int
 AS
 DECLARE @EndRow int
 SET @EndRow = @RowIndex + @MaxRows;

 DECLARE @j TABLE(id int IDENTITY, journalid int, datecreated datetime)
 IF EXISTS(SELECT * from dbo.[Journal_TypeFilters] WHERE ModuleId = @ModuleId)
 INSERT INTO @j 
 SELECT j.journalid, jt.datecreated from (
 SELECT DISTINCT js.JournalId from dbo.[Journal] as j
 INNER JOIN dbo.[Journal_Security] as js ON js.JournalId = j.JournalId
 INNER JOIN dbo.[Journal_User_Permissions](@PortalId,@CurrentUserId ,1) as t ON t.seckey = js.SecurityKey
 WHERE j.PortalId = @PortalId
 ) as j INNER JOIN dbo.[Journal] jt ON jt.JournalId = j.JournalId AND jt.PortalId = @PortalId
 INNER JOIN dbo.[Journal_TypeFilters] as jf ON jf.JournalTypeId = jt.JournalTypeId AND jf.ModuleId = @ModuleId
 ORDER BY jt.DateCreated DESC, jt.JournalId DESC;

 ELSE
 INSERT INTO @j 
 SELECT j.journalid, jt.datecreated from (
 SELECT DISTINCT js.JournalId from dbo.[Journal] as j
 INNER JOIN dbo.[Journal_Security] as js ON js.JournalId = j.JournalId
 INNER JOIN dbo.[Journal_User_Permissions](@PortalId,@CurrentUserId ,1) as t ON t.seckey = js.SecurityKey
 WHERE j.PortalId = @PortalId
 ) as j INNER JOIN dbo.[Journal] jt ON jt.JournalId = j.JournalId AND jt.PortalId = @PortalId
 ORDER BY jt.DateCreated DESC, jt.JournalId DESC;


 WITH journalItems AS
 (
 SELECT j.JournalId,
 ROW_NUMBER() OVER (ORDER BY j.JournalId DESC) AS RowNumber
 FROM   dbo.[Journal] as j INNER JOIN @j as jtmp ON jtmp.JournalId = j.JournalId
 WHERE j.PortalId = @PortalId
 )
 SELECT j.JournalId, j.JournalTypeId, j.Title, j.Summary, j.UserId, j.DateCreated, j.DateUpdated, j.PortalId,
 j.ProfileId, j.GroupId, j.ObjectKey, j.AccessKey,
 "JournalOwner" = '<entity><id>' + CAST(p.UserId as nvarchar(150)) + '</id><name><![CDATA[' + p.DisplayName + ']]></name></entity>',
 "JournalAuthor" = CASE WHEN ISNULL(a.UserId,-1) >0 THEN '<entity><id>' + CAST(a.UserId as nvarchar(150)) + '</id><name><![CDATA[' + a.DisplayName + ']]></name></entity>' ELSE '' END,
 "JournalOwnerId" = ISNULL(j.ProfileId,j.UserId),
 jt.Icon, jt.JournalType,
 "Profile" = CASE WHEN j.ProfileId > 0 THEN '<entity><id>' + CAST(p.UserID as nvarchar(150)) + '</id><name><![CDATA[' + p.DisplayName + ']]></name><vanity></vanity></entity>' ELSE '' END,
 jd.JournalXML, j.ContentItemId, j.ItemData, RowNumber
 FROM   journalItems as ji INNER JOIN 
 dbo.[Journal] as j ON j.JournalId = ji.JournalId INNER JOIN
 dbo.[Journal_Types] as jt ON jt.JournalTypeId = j.JournalTypeId LEFT OUTER JOIN
 dbo.[Journal_Data] as jd on jd.JournalId = j.JournalId LEFT OUTER JOIN
 dbo.[Users] AS p ON j.ProfileId = p.UserID LEFT OUTER JOIN
 dbo.[Users] AS a ON j.UserId = a.UserID
 WHERE  RowNumber BETWEEN @RowIndex AND @EndRow
 ORDER BY RowNumber ASC;
4

0 回答 0