Hello Koen,
I see that you want to pass parameters to your report. Please try using the followign code snippet and check if it helps you:
=======================================================================
ParameterFields crParameterFields;
CrystalDecisions.CrystalReports.Engine. ParameterFieldDefinitions parmdef;
ParameterField crParameterField;
ParameterValues crParameterValues;
ParameterDiscreteValue crParameterDiscreteValue;
ParameterField crParameterField;
ParameterValues crParameterValues;
ParameterDiscreteValue crParameterDiscreteValue;
crParameterFields = CrystalReportViewer1.ParameterFieldInfo;
crParameterField = crParameterFields["pfCustomer"];
crParameterValues = crParameterField.CurrentValues;
crParameterDiscreteValue = new ParameterDiscreteValue();
crParameterDiscreteValue.Value = "parameter value";
crParameterValues.Add(crParameterDiscreteValue);
CrystalReportViewer1.ParameterFieldInfo = crParameterFields;
=======================================================================
Let me know if this works.
Regards,
Venkat
On 11/8/05, Koen Willemse <[EMAIL PROTECTED]> wrote:
Hello everybody,
I'm trying to create a crystal report from my C# code. I call it the
way that I saw in a tutorial, but it seems that the parameter is not
passed, although, when I look in debug mode, the parameter gets a
value. Could anybody help? I've got a parameterfield in the report
called: pfCustomer
Now the code I use to set the parameters to the report is the
following:
// new report document object
ReportDocument oReport = new ReportDocument
();
// loading the ItemReport in report document
oReport.Load (reportLocation);
// set the selected report as the source
crystalReportViewer1.ReportSource = oReport;
// all the parameter fields will be added to
this collection
ParameterFields paramFields = new
ParameterFields();
// the parameter fields to be sent to the
report
ParameterField pfCustomer = new ParameterField
();
// setting the name of parameter fields with
wich they will be recieved in report
pfCustomer.ParameterFieldName = "pfCustomer";
// the above declared parameter fields accept
values as discrete objects
// so declaring discrete objects
ParameterDiscreteValue dcCustomer = new
ParameterDiscreteValue();
// setting the values of the discrete objects
dcCustomer.Value = reportParameters
["Customer"];
// now adding these discrete values to
parameters
pfCustomer.CurrentValues.Add(dcCustomer);
// now adding all these parameter fields to
the parameter collection
paramFields.Add(pfCustomer);
// finally add the parameter collection to
the crystal report viewer
crystalReportViewer1.ParameterFieldInfo =
paramFields;
I hope anyone can help me!
Thanks in advance!
Koen
SPONSORED LINKS
Basic programming language C programming language Computer programming languages Programming languages C programming language Software programming language
YAHOO! GROUPS LINKS
- Visit your group "Microsofts_C_Sharp" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
YAHOO! GROUPS LINKS
- Visit your group "Microsofts_C_Sharp" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
