Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing parameters programmatically
Message
General information
Forum:
ASP.NET
Category:
Reporting
Environment versions
Environment:
C# 2.0
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01393157
Message ID:
01393168
Views:
49
>I am providing an interface in .NET for users to choose the criteria for the data in the report. I would like to pass a parameter to Crystal Reports to give it a title and subtitle for the report. It looks like all the parameters require user input. Is there a way just to pass parameters to the report with no user intervention? Thanks.

Yes, assume Crystal is expecting two string parameters, Title2 and Title2:
#region Report Parameters
            //Pass the parameters for Title1 and Title2 to Crystal
            // all the parameter fields will be added to this collection 
            ParameterFields paramFields = new ParameterFields();
 
            // the parameter fields to be sent to the report 
            ParameterField pfField1 = new ParameterField();
            ParameterField pfField2 = new ParameterField();
 
            // setting the name of parameter fields with wich they will be recieved in report 
            pfField1.ParameterFieldName = "Title1";  // just the variable name we used (carryover from old VFP report)
            pfField2.ParameterFieldName = "Title2";  // secondary report title variable name
 
            // the above declared parameter fields accept values as discrete objects 
            // so declaring discrete objects 
            ParameterDiscreteValue dcField1 = new ParameterDiscreteValue();
            ParameterDiscreteValue dcField2 = new ParameterDiscreteValue();
 
            // setting the values of discrete objects 
            dcField1.Value = "Primary Report Title";  //Title1  you can get from anywhere, here for example I just plug it in
            dcField2.Value = "SubReport Title";        //Title2
 
            // add discrete values to parameters 
            pfField1.CurrentValues.Add(dcField1);
            pfField2.CurrentValues.Add(dcField2);
 
            // now adding all these parameter fields to the parameter collection 
            paramFields.Add(pfField1);
            paramFields.Add(pfField2);
 
            // add the parameter collection to the crystal report viewer 
            this.crystalReportViewer1.ParameterFieldInfo = paramFields;
#endregion
Just wanted to add this forum is a really good resource for Crystal Reports and .net:
https://www.sdn.sap.com/irj/scn/forum?forumID=45
(Sometimes the link doesn't work and you have to navigate to the Crystal Reports forum)
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform