Passing parameters to crystal reports in C# -


I am trying to work it for a while, and I have seen that all the example codes are not enough What am i doing

I have a program that gives a PDF of a report that I pass to the data table. It works fine, besides this I want to pass some other parameters (table date range, statistics etc.) and I can not get it to work. My code basically looks like this.

  report document myDataReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument (); MyDataReport.Load (@ "C: \ Layout \ Report.rpt"); Parameter myparam = new parameterfile (); ParameterDistrictVdKitValue = new parameterDiscoveryVolume (); MyParam.ParameterFieldName = "MyParameter"; MyDiscreteValue.Value = "Hello"; MyParam.CurrentValues.Add (myDiscreteValue); MyDataReport.ParameterFields.Add (myParam); MyDataReport.SetDataSource (myDataTable); Stream return data = myDataReport.ExportToStream (portable docformat); MyDataReport.Close (); Return return data;  

I have added the parameter field to the RPT document in crystal, do I have to change anything in the XSD file, or am I completely stripping something off?

Many thanks, Andy.

All the parameter code ...

  // set data Source first specify the parameter after myDataReport.SetDataSource (...) // set data source myDataReport.SetParameterValue ("MyParameter", "Hello");  

I do not remember the fact that when setting up data sources and parameters, in order related matters, Probably try to set the data source first, the crystal parameters of XSD / datasource have no relation.

UPDATE1

After the data source encoding, set the parameter value or you will get the "missing parameter value".


Comments

Popular posts from this blog

MySql variables and php -

php - Laravel - Overriding a resource route into a different route filter group -

url rewriting - How to implement the returnurl like SO in PHP? -