Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

18.03 Client Side Runtime Modifications

Making Client Side Runtime Modifications

Report web services can have a minor number of modifications made to them during runtime. As you learned in Chapter 14, the most flexible way to make runtime report modifications is by using the ReportDocument class. It is far more robust than the viewer control which only has a few properties. Unfortunately, a web service report is generated on the server and consequently this is where the ReportDocument object is instantiated. The client is restricted to using the viewer control and doesn’t have any access to the ReportDocument object.

Only being able to use the viewer control is disappointing. It can only do three things: set the record selection formula, set parameters, and set user credentials for logging into the data source. It can’t get direct access to all the report objects and their properties.

All the code samples that use the viewer to make runtime modifications will work unchanged for report web services. Here is a quick example just to illustrate it. Listing 18-4 demonstrates adding a discrete parameter. It uses the EmployeeList web service created earlier.

Listing 18-4. Setting the parameter of a report web service.
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
CrystalReportViewer1.ReportSource = _
"http://localhost/VBWebService/EmployeeListService.asmx"
Dim ParameterField As CrystalDecisions.Shared.ParameterField
Dim DiscreteValue As New CrystalDecisions.Shared.ParameterDiscreteValue
ParameterField = CrystalReportViewer1.ParameterFieldInfo ("LastName")
DiscreteValue.Value = "B*"
ParameterField.CurrentValues.Add(DiscreteValue)
End Sub

The first step is to assign the web service to the viewer. Then it gets a reference to the report parameter LastName and gives it a filter string. When the application runs it displays the report using the LastName parameter as a filter. This example could have just as easily logged into a database or set the record selection formula.