0
votes

In SSRS, a Date Time parameter on Preview is not matching the deployed report. Is this something someone else has encountered? The RDL code is identical. Is it the fact that, sometimes, a local preview is just a simulation of functionality? Is it because the display in preview sometimes uses cached data?

I have a SSRS report that, when I preview it in Visual Studio locally, the date shows as 2/10/2019 but when the RDL code is deployed on the server, the date shows as 2/7/2019. The date time variable is based on a parameter on the report, called rundate, and it has a Default Value of 2/10/2019. So I think the same thing should happen on the Report Server that happens locally in preview mode.

The report has four datasets and, as a test, I have set each four to have the SQL line that sets the rundate value like so: SET @rundate = '2019-02-10' but on the report server, when I load the report, it throws this error: Must declare the scalar variable "@rundate". Must declare the scalar variable "@rundate". It is in a cascading tabbed error message that looks like this: An error occurred during client rendering. An error has occurred during report processing. Query execution failed for dataset 'ThirdDataset. Must declare the scalar variable "@rundate". Must declare the scalar variable "@rundate".

So, why does it run locally and not on the server? The "ThirdDataset" is a false name I have given here. The actual name is redacted. But, I have noticed that this would be the first dataset run if they are run alphabetically. So this leads me to the question: why doesn't the report recognize this as a parameter and why does it complain that it is not declared?

============

UPDATE:

I have set the rundate to be part of a data-driven subscription in a report like so:

SELECT convert (date, DATEADD (DAY, -2 , SYSDATETIME())) as rundate

enter image description here

Which is two days ago. Since it is 2/11/2019 today, the rundate parameter passed to the SSRS report on the server should be 2/9/2019.

For fun, to test this out, I set the Default Value rundate parameter to be 8/8/2018 in hopes that the data-driven report would set it properly.

enter image description here

In preview mode locally on Visual Studio, a textbox that set to show the [@rundate] Expression shows 8/8/2018 which is what I would expect, but the Datasets are designed to run off this parameter. Since there is nothing that the sql should retrieve from the database that is that old, the graphs and charts in preview mode should turn up completely empty. Why do they show data?!

Next, let's see what the emailed subscription alert says. It had the date of 2/11/2019 12:00:00 AM. If the data-driven subscription ran like it shouold ahve run, it should of had the date of 2/9/2019 from

SELECT convert (date, DATEADD (DAY, -2 , SYSDATETIME())) as rundate

Why did this not work?

On the SSRS server, the RDL file has a parameter default value of 2/11/2019 12:00:00 AM but why did the report get THIS default value? What am I doing wrong and how can I fix this?

enter image description here

As a test, I set this default date/time parameter to 12:12:34 for its time to see what would happen. It reveiled that, yes, this is the date time stamp that is being sent to the report. So I unchecked the "Has Default" box enter image description here

Then, I noticed in the Step 5 of the data-driven subscription I could not advance to Next > without making a small change:

enter image description here

So, what should happen? Will it show the wacky 8/8/2018 value? Will it show the date from two days ago?

2
What do you mean saying "parameters do not match"? If a user enters a different value using the deployed report than you do in your development tool, the values of course "do not match".Wolfgang Kais
Are the month and day reversed from your development preview to the deployed report?aduguid
I have updated the original postxarzu
@xarzu Can you show your Sql statement? It looks like something is going wrong thereChris Latta

2 Answers

1
votes

Default values for report parameters are deployed only once to the report server, and then they keep their default value after subsequent deployments. This is so that default parameter values used in development don't overwrite the desired parameter defaults on the production server.

So it looks like when the report was first deployed, @rundate had the default value 2/7/2019 but has since been changed on the local report to 2/10/2019. Go into your report server, find the report and go into the Report Parameters section to edit the parameters and change the default value to what you want it to be (deleting the report from the report server and re-deploying it with the updated parameter will have the same effect, but note that the parameter will maintain that default value going forwards). Alternatively, set the report parameter using an expression so that it is continually up to date.

Regarding updating your parameter value in the Sql statement using the SET statement, you can't actually do it that way - you need to set it in the report's parameter list so that SSRS can set the parameter value. Consequently, your databse server is complaining that you are trying to set the value of a local variable that hasn't been defined in your Sql statement, and thus throws an error message.

So you need to set up the Report Parameters in the report parameters section in the report designer. Your Sql can then reference your parameters like so:

SELECT * FROM MyTable WHERE SomeDate >= @rundate

The parameters normally get mapped into your dataset automatically but you might want to check this by going into the Parameters settings on your dataset to make sure. If the parameter doesn't exist there, set it up.

0
votes

After lengthy trial and error, I found that the answer was to NOT have the parameter set to have a default value on the SSRS Report Server.