hi i am new to crystal reports and ASP.NET I have a crystal report and all i want is to pass one parameter to that report via my asp.net page
here is the code that i m using
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();
ParameterDiscrete开发者_如何学JAVAValue 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;
}
I am continously getting an error missing parameter values i don't know whats wrong with this code.. please help me
You have to pass parameter to your Crystal Report Source
. like...
CrystalReportSource1.ReportDocument.SetParameterValue(0, "ParameterValue");
精彩评论