【问题标题】:ASP.NET c# Pass Parameter Value to Crystal ReportASP.NET c#将参数值传递给Crystal Report
【发布时间】:2011-05-13 07:19:52
【问题描述】:

嗨 我是水晶报表和 ASP.NET 的新手 我有一份水晶报告,我只想通过我的 asp.net 页面将一个参数传递给该报告

这是我正在使用的代码

    protected void setParameterField()
{
    string strReportPath = "\\\\fileserver\\crude Accounting\\reports\\MonthReportNew.rpt";
    string weekReportPath = "\\\\fileserver\\crude Accounting\\reports\\" + "WeekWise.rpt";

    try
    {
        if (!System.IO.File.Exists(strReportPath))
        { throw (new Exception()); }
    }
    catch (Exception ex)
    {
        Response.Write("You Might Not Have Permission To View This Report. Please Contact System Administrator");
        Response.Write(Convert.ToString(ex.Message));
        return;
    }

    //Main Report
    ReportDocument cryRpt = new ReportDocument();
    cryRpt.Load(strReportPath);
    //Sub Report - Week
    ReportDocument weekReport = new ReportDocument();
    weekReport.Load(weekReportPath);

    ParameterFields paramFields = new ParameterFields();
    ParameterField paramField = new ParameterField();
    ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
    paramField.Name = "@Document_No";
    paramDiscreteValue.Value = "BAD-0511-PRO-2";
    paramField.CurrentValues.Add(paramDiscreteValue);
    paramFields.Add(paramField);

    CrystalReportViewer1.ParameterFieldInfo = paramFields;
   cryRpt.SetParameterValue("@Document_No", "BAD-0511-PRO-2");
    cryRpt.SetDatabaseLogon("myuserid", "mypassword");        
    CrystalReportViewer1.ReportSource = cryRpt;

}

我不断收到缺少参数值的错误 我不知道这段代码有什么问题.. 请帮帮我

【问题讨论】:

    标签: c# asp.net crystal-reports parameter-passing report


    【解决方案1】:

    您必须将参数传递给您的Crystal Report Source。喜欢...

    CrystalReportSource1.ReportDocument.SetParameterValue(0, "ParameterValue");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-25
      • 1970-01-01
      • 2023-03-21
      • 1970-01-01
      相关资源
      最近更新 更多