gpt4 book ai didi

c# - ASP.NET c# 将参数值传递给 Crystal Report

转载 作者:行者123 更新时间:2023-11-30 22:38:47 25 4
gpt4 key购买 nike

嗨我是 Crystal Reports 和 ASP.NET 的新手我有一份 Crystal 报告,我只想通过我的 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;

}

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

最佳答案

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

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

关于c# - ASP.NET c# 将参数值传递给 Crystal Report,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5988568/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com