简体   繁体   中英

Data will not show if 'View Report' button isn't clicked in SSRS

I'm using Reporting Services to show some data from a dataset in SQL Server, which has two parameters. Now, if the button 'View Report' isn't clicked, the data won't show on page load (Preview tab in Visual Studio / Web Browsing at localhost). What can I do that on page load, the data would show n.netheless if parameters are filled or not?

I have tried changing SQL code to include IF conditionals so that if parameters are null, select all the data, ELSE , display data by parameters but this didn't work, it seems like the query of data set is executed only when clicking the 'View Report' button.

Currently, I am using this SQL code which works fine when searching with filled parameters and clicking the aforementioned button:

IF(@SearchName IS NULL OR @SearchName  = '')
SELECT * FROM dbo.person;
ELSE
SELECT * FROM dbo.person WHERE ((name LIKE '%' + @SearchName + '%') OR (surname LIKE '%' + @SearchSurname+ '%'));

The expected outcome is returning all the data set ( SELECT * FROM dbo.person ) unless the parameter is filled and the button is clicked.

You need to give the parameters a default value in the report; in this case it seems it needs to be NULL .

Right click your parameter in the Report Data pane and go to Parameter Properties. Ensure that the property "Allow null value" is enabled. Then go to the Default Values pane, select "Specify values" and the Add. Then OK.

I just ran into the same issue - in my case it was caused by my default value(s) query for one of my parameters returning rows that are not present in my available values query results. This is not immediately obvious as the erroneous rows aren't shown (because they are not in the available list)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM