SSRS: ASP.NET ReportViewer parameters reset to default when clicking View Report - reporting-services

I have a SQL Reporting Services report (SQL 2008 built using Report Builder v2.0) which has a multi select integer parameter (in this case a list of stores).
The default value is 0 ("All Stores"). The parameter is passed to a stored procedure as a varchar(1024).
This all works fine in Report Builder or from the Reporting Services website.
However from an ASP.NET website using the ReportViewer component the parameters are reset to the default each time you choose "View Report".
I've tried setting the view to non-asynchronous loading (changes the rendering container?) plus any other setting I could find, without success. Does anyone know a trick to fix this?

I made a mistake. The ReportViewer control was inside a Master Page. Each time the "View Report" button was clicked it did a postback and reset the session.
I added if (!IsPostBack) to before the report setup method.

For those of you who experience this error for reasons not listed by the original poster...
Here is a similar scenario.
You have a report which uses a multi-select report parameter.
This parameter is populated by a datasource, which bases its values off some table query.
When you use the 'Select All' option for this report parameter and press the 'View Report' button, the parameter is reset to blank and your report is not generated.
I believe this problem occurs because something invalidates your dataset while the query is being performed, but I cannot be 100% certain.
What I do know, is that by using a table variable as the dataset's query source, you make this problem go away.
For example, your CityDataSource could be populated by the query:
SELECT DISTINCT city, city as SortOrder from accounts
UNION
SELECT 'All' as city, '0' as SortOrder
ORDER BY SortOrder
If you've been making SQL Reporting Services reports, you may have stumbled upon this solution once or twice.
Now, we change the CityDataSource query to look like the following:
DECLARE #citytable TABLE (city varchar(255), sortorder varchar(255))
INSERT INTO #citytable (city, sortorder) VALUES
(
SELECT DISTINCT city, city as SortOrder from accounts
)
SELECT city, sortorder FROM #citytable ORDER BY sortorder
And by doing that your report's parameters won't reset anymore.
A stored procedure would also work, I suspect.

I found a similar code error as the original poster. I was (re)setting the report server credentials every time the page was loaded, instead of just when it was initialized. Apparently, setting the report credentials resets all of the parameters.

Related

Getting a "one or more parameters required to run the report have not been specified" error

I am building a report that I would like to accept two values from the user, feed those into a query, and find the data associated with those entries.
For example, if you had a list of employees, performance measures, and values associated with those; then the user would select an employee name / performance measure, and they would get the scoring information on that employee for that measure.
I have two parameters, each being populated from SQL queries getting a distinct list of employee names and measures, and a table below that just pulls up information based on ~ 'WHERE name = #Name AND measure = #Measure' but when I click 'Preview' to run the report locally I get the error: "one or more parameters required to run the report have not been specified"
I know the parameters are working properly because I can feed their values directly into a textbox and the values populate correctly. Also, if I change the query to just accept one parameter (i.e. WHERE measure = #Measure) the query works.
I'm confused as to why this error is occurring since I know my parameters are functioning and being populated properly.
I experienced this behavior in .NET 4.0 using Local Reports (in .rdlc files), when one of the parameter's values was containing an emtpy string. Although setting the parameter was correct:
report.SetParameters(
new List<ReportParameter> {
new ReportParameter("Title", Messages.Title),
new ReportParameter("SubTitle", Messages.Subtitle))
}
);
It worked only as long as both parameters actually contained some characters, otherwise the mentioned exception was thrown.
This error is caused when you either
A) the parameter is spelled wrong in the actual report. Meaning that the query is expecting #Name but the report is passing #Names (or some other spelling).
or
B) Is it possible you are attempting to run the report with a default value on the parameter of NULL for #Name but the stored procedure requires an actual value?
This might be happening if you are building the report in Visual Studio and gave the #Name parameter a default value of (null).
Try removing the default value or making sure you #Name parameter has an actual value, even if it's just ''.
I had similar issue. Issue happened when you use SharedDataSource with parameters that are to have null value. If you use same query in embeded data source, there is no problem.
Unlike embebed data source, you have to define if parameters used in query of shared data sources are allowed to have null value as highlighted in screenshot here. In my case, there are two parameters in query of shared data source, that can have null value.
So after setting them to allow null, problem fixed!
This caused me many hours of pain. Turns out that it's to do with using a shared dataset.
Embed the dataset within your report instead and it works fine.
For me, setting the value of the parameter makes problem. I don't know why, but the parameter value was not able to accept a string.Empty or null. So i just gave a " " as value solves the error.
Sample
ReportParameter[] parameters = new ReportParameter[4];
parameters[0] = new ReportParameter("Name", EName);
parameters[1] = new ReportParameter("ShiftName", CurrentShift);
parameters[2] = new ReportParameter("Date", LoginDate);
if(ValidateReportData())//some condition
{
parameters[3] = new ReportParameter("Date1", LoginDate);
}
else
{
//parameters[3] = new ReportParameter("Date1", string.Empty);//this makes exception while calling Render function.
parameters[3] = new ReportParameter("Date1", " ");//Solves the issue.
}
I was having the same problem, it is now sorted on sql server 2008 r2.
I know this is now an old question,
but just to help others:
It was very simple really, just making sure the spelling including the case is the same and the use of #.
I have a shared dataset called currentSpaceByDrive with the following code:
SELECT
[DRIVE]
,[Volume_Size_GB]
,[VolumeSpaceAvailable_GB]
,[VolumePercentAvailable]
FROM monitoring.dbo.currentSpaceByDrive(#ServerID)
I add the shared dataset currentSpaceByDrive to my report and I give it the same name.
when I right click on it, the one on my report, dataset properties, the parameter is #ServerID.
#ServerID value comes from another dataset, called the_servers (where the user selects a serverID)
I have a report parameter also called #ServerID that gets its value from the_servers and is used to feed the #ServerID parameter on currentSpaceByDrive.
Too many #ServerID, I understand, but if you do your own test based on this, you will get it done.
See the image attached.
hope this helps
marcelo
check DataSet In Report Server , I had Similar Problem , I was Editing Shared Dataset in Visual Studio , but it didn't work , after an hour of frustration I checked dataset in report server and I found out it Is not updating with changes I made in visual studio , I Delete it and Redeploy Dataset Again from visual studio . it works .
Actually I had to:
Delete the SubReport object from the report.
Drag new object from Toolbox
Setup the SubReport name and report
In Paramateres "Add", and choose each parameter, and related value.
Then is works for me.
I think I have same issue my Parameter Supervisor is blank when I choose "Select All" which causes the error "One or more parameters were not specified for the subreport", but if I select a few supervisor name then the sub-report appears. It is puzzling because the Manager parameter value shows all value when "Select All" is checked, but it is not working on my Supervisor parameter. Note that Supervisor parameter is dependent on manager parameter.
I'm using shared DataSets for several reports, and the root cause of this issue was not mapping the input parameters from the report itself to the parameters of the shared dataset.
To fix, I navigated to the "Report Data" panel, opened the dataset (which is really linking to a shared dataset), clicked the "Parameter" tab, and then mapped the report parameters to the parameters of the shared dataset.

report builder 3.0 cascading parameter for bool

I am building a report in SSRS 2008 R2 Report Builder 3.0. In this report i have a Parameter named #CustomerID, a list of Customers in a dropdown. I then have a number of Bool Parameters eg. #UseFirstName and #UseLastName which are based on settings for each. The population of #UseFirstName and #UseLastName work fine for the first customer i choose but when i choose a new customer the values are not updated.
Obviously the population the first time is working against the dataset but after that it stops getting updated when i choose customer in the dropdown. Any ideas?
i have set "always update" on all my parameters.
Code for getting the parameter data:
SELECT * FROM pen.CustomerReportSettings
WHERE (CustomerID = #CustomerID)
I don't think the bool parameter radio group will work the way you want it. The only thing I can think of that will get you close is to force the bool parameters to a text datatype and set the default values to "Get values from a query" with the value field being the field related to the parameter. You also need to specify the Available Values as "Get values from query" to force the parameter to reload when the #CustomerID changes. This should yield a drop down box with one selectable option and the value of the dropdown set to that option.

SSRS Null Hidden Parameter in SharePoint Integrated Mode

I have a report (call it Report A) that was built using only the User!UserId to generate appropriate data for that person. This worked perfectly.
The feature was requested to be able to view other people's data through Report A, based upon security inside the underlying stored proc. I updated Report A to include a new parameter, EmployeeId, and created a new front screen report that has a "Go To Report" action, passing the EmployeeId. The Stored Proc takes both the UserId and EmployeeId, and returns the data for the requested employee, if the User has permission to see the data. This also works perfectly.
I set the EmployeeId parameter to be hidden, and a default value of null. This was to allow anyone who comes directly to Report A to be able to run for their data (no impersonation), as they are used to. Running from within BIDS, it works, but once I publish to SharePoint, I get:
"The report is missing a parameter value but prompting for it has been disabled."
I obviously don't want to prompt for the parameter, and value should be null in this case. Does SharePoint integrated mode not allow for hidden and null parameters?
In SSRS 2008 with Sharepoint, you need to prefix each parameter passed in the URL with "rp:". For example: URL.../RSViewerPage.aspx?rv:RelativeReportUrl=/TestReports/Orders.rdl&rs:Command=Render&rp:CLordID=1324381
From this MSDN page, it looks as though you may need to explicitly override the parameter value to set it to be null in the Manage Parameters dialog within the library/folder containing the report.

How to stop Reporting Services report from rendering automatically on startup?

I notice that if a report has default values specified to all its parameters then it renders automatically on startup. How can I prevent this? that is, I don't want the report to be rendered until the user clicks the 'view report' button
There is no way to stop the report rendering if all parameters have default values.
The only way to stop the report rendering automatically is to have at least one parameter without a default value.
I have achieved from the below solution:
If you are using ReportViewer its posible to set the property ShowReportBody="False". Then on the OnSubmittingParameterValues event, change the ShowReportBody property to true. Then you do not need any extra parameters or parameters without default value in the report.
<rsweb:ReportViewer
ID="_rv"
runat="server"
Width="100%"
Height="100%"
ShowReportBody="False"
ShowPrintButton="false"
OnSubmittingParameterValues="rv_SubmitParamValues"/>
And then in rv_SubmitParamValuesmethod:
this.rv.ShowReportBody = true;
This is tested in SSRS2019 build 15.0.1102.962 (Apr 2022)
PROBLEM:
A report is opened, auto-fires, and renders all rows which is undesirable. Report parameters that use null are usually the culprit. In my case null is sent to a stored proc which detects that as a request to return all rows.
SOLUTION:
Auto-fire cannot be prevented but it can be short-circuited cleanly using a technique which mimics the 'select a value' option one may see in the dropdown.
AS SHOWN:
Use a Query to build Dataset 'ReportMenu' which has 3 fields
AcctName: Displayed in the dropdown
AcctId: Sent to a stored proc
SortOrder: Forces the 'Select a Client' row to the top.
-- Query to Build Menu Dropdown
-- Use any verbiage for the strings it doesn't matter
SELECT '' as AcctID, '<Select a Client>' as AcctName, 1 as SortOrder
UNION
SELECT NULL, '- ALL -', 2
UNION
SELECT AcctID, AcctName, 3
FROM vw_Get_Active_List -- or hardcode if preferred
ORDER BY SortOrder, AcctName
The report auto-fires when loaded using param 'Select a Client'
Since '' isn't valid my procedure returns no rows.
The report can now be used normally.
Users can select - ALL - to get all clients from the
dropdown or choose from the list provided by the view.
Hope this helps !

Parameter missing a value

I am new to reporting services and have a reporting services 2005 report that I am working on to use as a base report template for our organization. I am trying to place the date that the report was last modified on the report server into the page header of the report. However, I keep getting a 'ParamX' parameter is missing a value error when I try to This is what I have done:
Set up a Parameter ReportName with a default value of Globals!ReportName. It is also hidden and internal.
Set up a Dataset ReportHeader that calls a stored procedure that returns the date the report was last updated or another date, if the report is not on the report server. It has a parameter #ReportName assigned to the Parameter!ReportName.Value. The Dataset returns values when run on the dataset tab in the BI tool.
Set up a Parameter ReportVersion that has a default value Query From based on the dataset ReportHeader and picking the ModDate column. It is the last parameter in the report parameters list.
I assign a textbox to the parameter.
When I preview, I get "The 'ReportVersion' parameter is missing a value whether I place it in the report body or page header (which is where I want it). I have deleted and added the parameter again, toyed with the hidden and internal settings on it.
What does this error really mean, what I am missing, and can I even do this with parameters?
Thanks In Advance
Jim
If I understand what you're doing, it sounds like you want to be using a field where you're implementing a parameter...
You are returning the ModDate from the data source, correct? If you're doing this, you can simply throw a text box in there, and use something like this: =Fields!modDate.Value to display it.
Parameters are values that go in to the query, fields are what it returns.
Hope this helps...
EDIT:: OK so are you trying to retrieve the mod-date column value from the reportserver db? If that's what we're talking about, you'll need to add a few things to the report. Add a datasource to report db, a dataset containing the date (query below), a list object in the report linked to the dataset, and a textbox in said list object to display the field. If you hit the report server with a query like this:
SELECT MAX(ModifiedDate) AS ModDate FROM catalog WHERE name='myReportName'
That will return your modifieddate from the ReportSErvices Database as a field that you can use.