How to solve error: This report requires a default or user-defined value for the report parameter '*'

16,282

Solution 1

When working with external web services it's important to realize that each request made through an instance of automatically generated wrapper class is tied to all other calls made through that instance. So here one PdfGenerator class is being instantiated, but the four threads that are making calls to it are making them all through the same interface so that you have:

Thread A: Setup Parameters
Thread B: Setup Parameters
Thread A: Execute (consuming thread B's parameters)
Thread B: Execute (no parameters given, exception thrown)

Each thread will need its own instance of the PdfGenerator class in that each one needs its own instance of the ReportExecutionService

Solution 2

For others looking for answers on this subject (google search brought me here) it can also be caused by a parameter being defined as "From Query" rather than "Non Queried". Then if you pass in a parameter that is not valid as per the query, you can get this error. For instance, you have a parameter called CustomerId which is presented via the web interface as Select CustomerId, CustomerName from Customer Lets say valid customer ids in the database are 1 to 10. If you pass in a parameter in c# with a value of 24, (Ie out of that range) RS acts as if the parameter was never passed in since it detects it is not in the valid range. hope this helps

Solution 3

Stumbled across this question: my situation is simpler (no multi-threading, one report), but I was getting the same message.

I have two versions of a lookup table that are poorly synchronized (topic for another post). One of the parameters for this report is looking for values from this table. As the synchronization had not occurred yet, basically I was passing a parameter with no corresponding value. The error message I was getting back was that I had not supplied a parameter when, really, I had supplied a "bad" parameter. Frustrating.

Solution 4

In my case the problem was the available values had extra spaces at end of value so 'ABC001' did not equal the value from the query 'ABC001 ' so it was an invalid value and it acted as if i never sent the parameter at all. I went into the query that build the available values and trimmed.. so moral of the story... always trim! lol.

Share:
16,282
Orion Adrian
Author by

Orion Adrian

Updated on June 05, 2022

Comments

  • Orion Adrian
    Orion Adrian almost 2 years

    I'm getting the error:

    This report requires a default or user-defined value for the report parameter '*'. To run or subscribe to this report, you must provide a parameter value.

    very occasionally from my reporting server even when the value '*' is being populated. Any ideas or leads that might allow me to track it down? Some points.

    • I run the reports 4-way asynchronously (meaning 4 threads generating reports at a time).
    • The reports have 2 provided parameters (always supplied) and one derived parameter.
    • I run 1,000 reports per session with ~250 reports per thread.
    • Sometimes the error will hit after a few seconds, sometimes after many hours.

      using System;
      using System.Globalization;
      using System.IO;
      using Cns.ReportExecution2005;
      
      public class PdfGenerator
      {
          private readonly ReportExecutionService reportExecutionService;
          public PdfGenerator(string executionServiceAddress)
          {
              // Create a new proxy to the web service
              this.reportExecutionService = new ReportExecutionService
                                                {
                                                    Credentials = System.Net.CredentialCache.DefaultNetworkCredentials,
                                                    Url = executionServiceAddress
                                                };
          }
          public Stream GenerateReport(string reportName, string format, ReportGeneratorParameter[] parameters)
          {
              if (reportName == null)
              {
                  throw new ArgumentNullException("reportName");
              }
              if (format == null)
              {
                  throw new ArgumentNullException("format");
              }
              this.reportExecutionService.LoadReport(reportName, null);
              if (parameters != null)
              {
                  var executionParameters = new ParameterValue[parameters.Length];
                  for (int i = 0; i < parameters.Length; ++i)
                  {
                      executionParameters[i] = new ParameterValue
                      {
                          Label = parameters[i].Name,
                          Name = parameters[i].Name,
                          Value = Convert.ToString(parameters[i].Value, CultureInfo.InvariantCulture)
                      };
                  }
                  this.reportExecutionService.SetExecutionParameters(executionParameters, "en-us");
              }
              string extension;
              string encoding;
              string mimeType;
              Warning[] warnings;
              string[] streamIDs;
              byte[] results = this.reportExecutionService.Render(format, null, out extension, out encoding, out mimeType, out warnings, out streamIDs);
              return new MemoryStream(results);
          }
      }