Visual Studio .NET - Loading Crytal report with Parameters and subreports in

Asked By Ralph Acido on 01-Feb-07 10:22 PM
how to load Crytal report with Parameters and subreports in  1.1?

hope these links helps! - sundar k replied to Ralph Acido on 01-Feb-07 10:59 PM

Pass Database Logon to Subreport in CR for .Net C# Webapp

This C# .NET sample application demonstrates how to log onto a data source for a main report and subreports.

Pass Data Range Parameter to a subreport in CR for .NET C# Web app

This C# .NET sample web application demonstrates how to pass a date range to a date Range Parameter in a subreports using the CrystalReportViewer.

Working with ASP.NET and Crystal Reports 9 with or without RAS 9

Passing SQL logon information to a report and subreport in VB .NET

Crystal Subreport with

Sushila Patel replied to Ralph Acido on 01-Feb-07 11:08 PM

Check out the link

below is code from link


 // Create parameter objects
  ParameterFields myParams = new ParameterFields();
  ParameterField myParam = new ParameterField();
  ParameterDiscreteValue myDiscreteValue = new ParameterDiscreteValue();

  // Set the ParameterFieldName to the name of the parameter
  // created in the Field Explorer
  myParam.ParameterFieldName = "Country";

  // Add first country
  myDiscreteValue.Value = "USA";

  // Reuse myDiscreteValue, and assign second country
  myDiscreteValue = new ParameterDiscreteValue();
  myDiscreteValue.Value = "Netherlands";

  // Add param object to params collection

  // Assign the params collection to the report viewer
  myCrystalReportViewer.ParameterFieldInfo = myParams;

  // Assign the Report to the report viewer.
  // This method uses a strongly typed report,
  // but other methods are possible as well.
  myCrystalReportViewer.ReportSource = MyReportObject;


Re :: Loading Crytal report with Parameters and subreports in

SP replied to Ralph Acido on 21-Nov-08 06:45 AM


(1) Add the parameter that you require for the subreport to the main report. To do this open the Field Explorer window, right click Parameter Fields and select new. If you are using a stored procedure for the subreport use the same name for the parameter as you have used in the stored procedure e.g. @De_ID; Also ensure that the datatype for the parameter is compatible with the stored procedure e.g. Use number if the stored procedure parameter type is int.

(2) Once you have added your parameter right click the subreport and select Change Subreport Links... This will open the Subreport Links window. Scroll down the Available Fields Treeview in the top left of the window. Under Report fields locate the parameter you added in step one. Select the parameter and press the > button. Click the "Subreport parameter field to use:" dropdownlist and select your parameter from the list. Press the OK button. Now the subreport should use whatever value is in the parameter you added to the main report in step 1.

(3) You can populate the value of a reports parameter programatically by doing the following.

Dim pv As Integer = 1 'Parameter value
Dim pn As String = "@De_ID" 'Parameter name
reportDoc.SetParameterValue(pn, pv)

 Note you have to setup the Report Document object before you add parameters to it. See code above.

Good luck.

View Post for more details ::

Hope this helps

Re :: Loading Crytal report with Parameters and subreports in
SP replied to Ralph Acido on 21-Nov-08 06:46 AM

See this article for more details

Hope this helps.