Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 308
user2061929 Avatar asked Feb 28 '13 16:02

user2061929


4 Answers

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.

like image 83
Marcel Avatar answered Oct 03 '22 07:10

Marcel


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 ''.

like image 39
user2121425 Avatar answered Oct 03 '22 06:10

user2121425


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.

Set Allow Null for SharedDataSource Parameter(s)

So after setting them to allow null, problem fixed!

like image 37
Dk358 Avatar answered Oct 03 '22 06:10

Dk358


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.

like image 21
chris stevens Avatar answered Oct 03 '22 08:10

chris stevens