Databases Reference
In-Depth Information
First, I'll set all of the
ReportViewer
properties at design time using the properties window. After that,
I'll demonstrate the code that will set the same properties at runtime.
The report you want to display is the value entered for the
ReportPath
property, as shown in Figure 12-18.
Figure 12-18
The
ReportPath
property is the report location in the Report Server hierarchy. In this case, I've selected a
report on my local machine to display in the
ReportViewer
control. The location of the Report Server is set
using the
ReportServerUrl
property. The default Report Server URL is also displayed in Figure 12-18.
Since you're going to use the Report Server for processing, set the
ProcessingMode
property to Remote.
That will use the Report Server to retrieve source data that will be used in the report. In Remote mode,
the
ReportViewer
controls display reports that are hosted on a SQL Server 2005 Report Server. The
source data for those reports can come from any appropriate data source, not just SQL Server. This
behavior is normal report processing behavior. Setting the processing mode is shown in Figure 12-19.
With everything except the parameters set using the properties window, the only necessary code sets the
parameters and executes the report.
Parameters are managed as an array of
ReportParameter
objects. Note that the reference to the
Microsoft.Reporting.WinForms namespace is used to instantiate this object. Since the report has two
required parameters, the array is declared with a maximum element index of 1 to provide two elements.
Each of the elements is populated by passing the parameter name and value to each of the two the
ReportParameter
constructors.
Search WWH ::
Custom Search