Jan Schreuder on .Net

.Net code samples, experiences, observations

View my professional profile on LinkedIn

Recent Posts

Tags

News

  • Inappropriate comments will be deleted at my discretion.

    The information and code samples in this weblog is provided "AS IS" without warranty of any kind, either expressed or implied, including but not limited to the merchantability and/or fitness for a particular purpose.

Community

Email Notifications

Tool suppliers

Tools

General

Microsoft

Favorite blogs

Archives

How to: Set parameters on a Crystal Report

It is possible to add parameters to reports. Using these parameters you can allow users to set date ranges, or pass other information to a report. Using the following method, you can set the parameters:

/// <summary>
/// Set value for report parameters
/// </summary>
/// <param name="name">Parameter name.</param>
/// <param name="value">Value to be set for the specified parameter.</param>
public void SetParameter(string name, object value)
{
    //Access the specified parameter from the parameters collection
    CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition parameter = _reportDocument.DataDefinition.ParameterFields[name];
 
    // Now get the current value for the parameter and clear them
    CrystalDecisions.Shared.ParameterValues currentValues = parameter.CurrentValues;
    currentValues.Clear();
 
    // Create a value object for Crystal reports and assign the specified value.
    CrystalDecisions.Shared.ParameterDiscreteValue newValue = new CrystalDecisions.Shared.ParameterDiscreteValue();
    newValue.Value = value;
 
    // Now add the new value to the values collection and apply the 
    // collection to the report.
    currentValues.Add(newValue);
    parameter.ApplyCurrentValues(currentValues);
}

Comments

sherif said:

How to: Set set date ranges on a Crystal Report
# August 1, 2006 10:41 PM

Martin said:

Hi, I have a report that has one OUT parameter, and one IN-OUT Parameter.  It links to an Oracle Stored Procedure.  My default value for the parameter was 5.

Im calling the report from a C# Windows application, and letting it export to a PDF file.

My report runs fine and exports perfectly using the default parameter.

But as soon as i set the parameter and then try export it then i get the error message: Error in file.. Failed to load database information.

It also mentions the crdb_oracle.dll file.

Why does this happen when i pass a parameter.  It works fine if i dont pass the parameter..?

Please help me..

TIA

Martin

# August 2, 2007 4:02 PM

pzkpfw said:

Thanks!

# August 14, 2008 6:33 AM

shafeeq said:

how i set a parameter manually in code

# September 13, 2008 9:39 AM

ai said:

how to clear on a crystal report

# November 17, 2008 6:31 AM

reetika said:

the code worked for me

Thnx ya.

# November 24, 2008 12:50 PM

ravindra joshi said:

thanks

# March 30, 2009 9:26 AM

gever said:

# May 5, 2009 9:04 AM

Guna said:

Thanks

# October 15, 2010 3:48 PM

Jegan said:

Thanks

# October 15, 2010 3:48 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Please add 4 and 5 and type the answer here: