Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Help with DNN 5 and SQLHelp with DNN 5 and SQL
Previous
 
Next
New Post
9/28/2009 9:31 PM
 

Hey everyone,

I'm having an issue with a SQL Procedure and am stumped as to what to do. The procedure works fine when I install the module on DNN 4.9.4 but gives me an error on DNN 5.1.2

Is there something I'm doing wrong? or has something changed between version 4 and 5 that is preventing this query from running?

 

............DNN 5.1.2 Error................

Error: is currently unavailable.
DotNetNuke.Services.Exceptions.ModuleLoadException: Operand data type nvarchar is invalid for minus operator. ---> System.Data.SqlClient.SqlException: Operand data type nvarchar is invalid for minus operator. 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.SqlDataReader.HasMoreRows() at System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout) at System.Data.SqlClient.SqlDataReader.Read() at DotNetNuke.Common.Utilities.CBO.FillListFromReader(Type objType, IDataReader dr, IList objList, Boolean closeReader) at DotNetNuke.Common.Utilities.CBO.FillCollection(IDataReader dr, Type objType) at LSpaceDesign.DNN.ArticleManagement.Business.ArticleCategoryController.List(Int32 portalID) at LSpaceDesign.DNN.ArticleManagement.CategoryEditor.EnsureParentCategoryListIsRetrieved() at LSpaceDesign.DNN.ArticleManagement.CategoryEditor.BindGrid(Int32 editID) at LSpaceDesign.DNN.ArticleManagement.CategoryEditor.Page_Load(Object sender, EventArgs e) --- End of inner exception stack trace ---




............Procedure.........

GO
CREATE PROCEDURE [dbo].[ArticleCategoryListPaginated]
    @portalID int,
    @pageSize int,
    @pageIndex int,
    @sortOrder nvarchar(500),
    @reverseSortOrder nvarchar(500)
AS
BEGIN
    DECLARE @sql nvarchar(4000),
            @recCount int,
            @skip int,
            @toFetch int

    SELECT @recCount = COUNT(*)
    FROM dbo.ArticleCategory
    WHERE PortalID = @PortalID
   
    SET @skip = @pageIndex * @pageSize
    SET @toFetch = @recCount - @skip
    SET @toFetch = CASE
                WHEN @toFetch > @pageSize THEN @pageSize
                WHEN @toFetch < 0 THEN 0
                ELSE @toFetch
             END

    SELECT TotalRecordCount = @recCount

    SET @sql = 'SELECT * ' +
               'FROM (SELECT TOP ' + CAST(STR(@toFetch) as nvarchar(10)) + ' * ' +
                     'FROM (SELECT TOP ' + CAST(STR(@toFetch + @skip) as nvarchar(10)) + ' * ' +
                           'FROM (SELECT TOP ' + CAST(STR(@recCount) as nvarchar(10)) + ' ' +
                                        'ac.[ArticleCategoryID], ' +
                                        'ac.[PortalID], ' +
                                        'ac.[CategoryName], ' +
                                        'ac.[CategoryDisplayName], ' +
                                        'ac.[Searchable], ' +
                                        'ac.[ParentCategoryID], ' +
                                        'ac.[UseForFiltering], ' +
                                        'ac.[CategoryTabID], ' +
                                        '[Path] = dbo.ArticleCategoryGetPath(ac.ArticleCategoryID, '' > ''), ' +
                                        '[DisplayPath] = dbo.ArticleCategoryGetDisplayPath(ac.ArticleCategoryID, '' > ''), ' +
                                        '[InheritedCategoryTabID] = dbo.ArticleCategoryGetCategoryTabID(ac.ArticleCategoryID), ' +
                                        '[Depth] = dbo.ArticleCategoryGetDepth(ac.ArticleCategoryID), ' +
                                        '[ParentCategoryName] = pc.CategoryName ' +
                                 'FROM dbo.ArticleCategory ac ' +
                                     'LEFT JOIN dbo.ArticleCategory pc ' +
                                         'ON ac.ParentCategoryID = pc.ArticleCategoryID ' +
                                 'WHERE ac.PortalID = @PortalID) x ' +
                           'ORDER BY ' + @sortOrder + ') x ' +
                     'ORDER BY ' + @reverseSortOrder + ') x ' +
               'ORDER BY ' + @sortOrder

    exec sp_executesql @sql,
            N'@portalID int',
            @portalID = @portalID
END

 

 
New Post
9/30/2009 3:09 AM
 

Hi , Kevin

I tried your script in DNN 5 and for 4 it's working. So what i suggest just do some try/error with your script may be you 'll get result.

thanks

Sahil

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Help with DNN 5 and SQLHelp with DNN 5 and SQL


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out