Crystal Reports in C#

G

Guest

I'm new to crystal reports and am a bit overwhelmed as to how i can display a
crystal report in my c# code. (especially with parameters!!!)

Can anyone recommend a (very) simple tutorial on this.

thank you.

CR
 
G

Guest

thank you for your references, I've been looking at them.

I have started working on the c# code that will build the report. The page
compiles but I get the error "Missing parameter field current value"

I have 3 parameters. One of them is a ParameterRangeValue for the date (
which i'm not sure how to use.)

Also when i try to give my ParameterFields the Name property I get the error
"'CrystalDecisions.Shared.ParameterField' does not contain a definition for
name".

I'd appreciate any insights that could be offered.

Below is the code sample:

private void Page_Load(object sender, System.EventArgs e)
{
string Type= (string)Session["Type"];
string reportType= Request.QueryString["reporttype"];
string groupBy = Request.QueryString["groupby"];
string reportDetail= Request.QueryString["reportdetail"];
string advertiser = Request.QueryString["advertiser"];
string startDate = Request.QueryString["startdate"];
string endDate = Request.QueryString["enddate"];


ParameterFields paramFields = new ParameterFields();
ParameterField paramField;
ParameterRangeValue paramRangeValue;
ParameterDiscreteValue paramAdvertiser = new ParameterDiscreteValue();
ParameterDiscreteValue paramType= new ParameterDiscreteValue();
ParameterRangeValue paramRange= new ParameterRangeValue();
ParameterValues paramValues;

//Build parameters and add them to the collection
paramField = new ParameterField();
//paramField.Name = "@AdvID";
//Error message = 'CrystalDecisions.Shared.ParameterField' does not contain
a definition for name
paramAdvertiser.Value = advertiser;
paramField.CurrentValues.Add(paramAdvertiser);
paramFields.Add(paramField);

paramField = new ParameterField();
//paramField.Name = "@Type";
paramType.Value = int.Parse(Type);
paramField.CurrentValues.Add(paramType);
paramFields.Add(paramField);

paramRangeValue = new ParameterRangeValue();
paramRangeValue.StartValue = startDate;
paramRangeValue.EndValue = endDate;
paramRangeValue.UpperBoundType = RangeBoundType.BoundInclusive;
paramRangeValue.LowerBoundType = RangeBoundType.BoundInclusive;
paramValues = new ParameterValues();
paramValues.Add(paramRangeValue);

string reportPath = "C://Inetpub//wwwroot//Report.rpt";
ReportDocument repDoc = new ReportDocument();
repDoc.Load(reportPath);

this.crvReport.ParameterFieldInfo = paramFields;
this.crvReport.ReportSource = repDoc;
}
 
O

Octavio Hernandez

CodeRazor,

a) I believe the ReportDocument class has a SetParameterValue(<name>,
<value>) that makes very easy assigning values to parameters (one single
call).
b) I have always avoided range parameters in Crystal, instead I always use
two date parameters and place them in the selection formula (this is only a
suggestion).

Regards - Octavio
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top