Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Passing Parameters to Crystal Reports 1

Status
Not open for further replies.

johnsun1976

Programmer
Jan 28, 2002
34
CA
Hi.. I'm having problems passing a parameter into a report so it can display the correct information.. I set a Parameter Field to the field I want to set a value to, but the report seems to always return everything.. Does anyone have any good reference on how to set up a report? I'm probably doing something wrong..
Thanks
John
 
Instead of passing parameters to the report, i found that using datasets worked a lot better, you access the database thru a stored procedure, get the DataAdapter, and fill your dataset from the DA.
Altho this would mean you would have to had created the report using the Dataset which you designed.
But this works very easily, with very little problems
 
I used an XML file that is written out to the hard drive, which is effect, a reflection off of a dataset. I beleive there is help on Crystal's web site to do this.
 
Don't know if this is still an issue or not, but I had the exact same questin as you, but I didn't like the answers you got. After you create the parameter, you simply create the Selec Expert in Crystal (icon with cogs). Double click the field under Report Fields that you created the parameter for. simple click "is equal to", and select your parameter field.

If you want to pass parameters programmatically, this link pretty much answered all my ?s.


Hope this helps.
 
I didn't have any luck with the MSDN link (I'm new at this), but the following code using the engine object model and a strongly typed report works for me. No guarantees that this is a good way to do it, but hopefully it will be helpful to someone.


ParameterValues paramValues = new ParameterValues ();
ParameterDiscreteValue paramValue = new ParameterDiscreteValue ();
reportName myReport = new reportName ();

// Set the discrete value and pass it to the parameter.
paramValue.Value = "whatever";
paramValues.Add (paramValue);
myReport.DataDefinition.ParameterFields[0].ApplyCurrentValues (paramValues);

// Assign report object to report viewer control
crystalReportViewer1.ReportSource = myReport;


You could keep going for any number of parameters, just make sure you set paramValue and paramValues = to new objects each time so the values don't overwrite each other.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top