The reports module is throwing exceptions for undeclared parameters that get parsed as DNN recognized values. that is, we have parameters such as @PortalId and @UserId, which are parsed by DNN when the module query runs.
If these are added as allowed URL parameters in the module an error is thrown. However, DNN recognizes these and gets the correct Portal Id, the logged in User ID, etc. as part of the process.
Here is one such query. The module runs and does what it is supposed to. If the variables are declared, this error is thrown:
There was an error executing the data source: There is an error in your SQL at line 2: The variable name '@PortalId' has already been declared. Variable names must be unique within a query batch or stored procedure. The variable name '@UserId' has already been declared. Variable names must be unique within a query batch or stored procedure.
But if they aren't declared Log4net and the Event Log pile up exceptions that the variables are not declared. As mentioned, using them as allowed URL parameters doesn't work. (I didn't think it would but had to try something). This error happens if PortalId, UserId are entered as allowed URL parameters:
There was an error executing the data source: There is an error in your SQL at line 1: Incorrect syntax near 'nvarchar'.
There isn't a lot of documentation on the module. How are these exceptions to be avoided? They can't be declared or put in as allowed parameters or the module shows an error, the Event Log / Log 4 Net loads up on errors if DNN is allowed to parse and use them.
SELECT
'Your Total Donations: $' + CONVERT(VARCHAR(10), SUM(CONVERT(DECIMAL(8,2), (CONVERT(MONEY, CP.Free3))))) AS ' '
FROM dbo.CAT_OrderDetails COD
JOIN dbo.CAT_Orders CO
ON CO.OrderId = COD.OrderId
JOIN dbo.CAT_Products CP
ON CP.ProductId = COD.ProductID
JOIN dbo.UserPortals UP
ON UP.UserId = CO.CustomerId
AND PortalId = @PortalId
AND UP.userId = @UserId
GROUP BY UP.USERID