如何解决错误:此报告需要报告参数"*"的默认值或用户定义值

Ori*_*ian 1 c# sql-server reporting-services

我收到错误:

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.

偶尔从我的报告服务器,即使正在填充值'*'.任何可以让我追踪它的想法或线索?有些观点.

  • 我以异步方式运行报告(意味着4个线程一次生成报告).
  • 报告提供了2个参数(始终提供)和一个派生参数.
  • 我每个会话运行1,000个报告,每个线程约250个报告.
  • 有时错误会在几秒钟后发生,有时会在数小时后发生.

    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);
        }
    }
    
    Run Code Online (Sandbox Code Playgroud)

Ada*_*SFT 8

对于其他寻找此主题答案的人(谷歌搜索带我到这里),它也可能是由参数定义为"从查询"而不是"非查询"引起的.然后,如果传入的参数根据查询无效,则可能会出现此错误.例如,您有一个名为CustomerId的参数,它通过Web界面显示为Select CustomerId,CustomerName from Customer Lets表示数据库中的有效客户ID为1到10.如果您在c#中传入一个值为24的参数, (即超出该范围)RS的作用就好像参数从未传入,因为它检测到它不在有效范围内.希望这可以帮助