DocumentLayout Class | ParameterDictionary Class | Programming with ReportWriter for .NET

Whenever reports require access to variables directly from the application's code then the use of the ParameterDictionary is needed. ParameterDictionary objects will hold a dictionary of named parameters to be used from within your defined report (your DPLX file). The ParameterDictionary object is created and parameters are added to it using the very simple C# code below:

[Visual Basic]
Dim MyParameters As ParameterDictionary = New ParameterDictionary()
MyParameters.Add("parameterName", param_value)
[C#]
ParameterDictionary parameters = new ParameterDictionary(); 
parameters.Add("parameterName", param_value );

The ParameterDicionary then needs to be passed into the Run method of the DocumentLayout object. This is exemplified in the C# code below:

[Visual Basic]
Dim reportDocument As DocumentLayout = New DocumentLayout("Report.dplx")
Dim MyDocument As Document = reportDocument.Run(parameters)
[C#]
DocumentLayout reportDocument = new DocumentLayout("Report.dplx"); 
Document document = reportDocument.Run( parameters ); 

The parameters passed into the Report’s Run method would then be used from within the DPLX file wherever the following is found:

          Parameters["param_name"]

For example, the parameters could be used from within a query (or stored procedure) as follows:

          SELECT * FROM Orders WHERE OrderID = #Parameters["OrderID"]#

Or a parameter from the ParameterDictionary could be referenced from within a Record Box by setting the value of the Record Box as follows:

          Value = "Parameters["name"]"

See Also 

DocumentLayout Class | ParameterDictionary Class | Programming with ReportWriter for .NET