ActiveReports 11
DataSet Windows Application
ActiveReports 11 > ActiveReports User Guide > Samples and Walkthroughs > Walkthroughs > Common Walkthroughs > Web > DataSet Windows Application

You can use a Web Service that returns a dataset as the data source for your reports in Windows applications. This walkthrough illustrates how to create a Windows client application that uses the dataset Web Service as the data source for an ActiveReports.

This walkthrough builds on the DataSet Web Service walkthrough and is split up into the following activities:

Note: For the information on how to connect your report to data and how to create the report layout, please see Single Layout Reports (for a page report) or Basic Data Bound Reports (for a section report).

To add a reference to a web service to the project

To add a reference to a web service in Visual Studio that is compatible with .NET Framework 2.0 Web service

  1. From the Project menu, select Add Service Reference.
  2. In the Add Service Reference window that appears, click Advanced button.
  3. In the Service Reference Settings window that appears, click Add Web Reference button.
  4. In the Add Web Reference window that appears, click the Web services on the local machine link.
  5. Click the link to the virtual directory you created in the previous walkthrough. You can get the address by running the project from the previous walkthrough and copying the url from the address in the browser. (It will look something like http://localhost:####/DataSetWS/Service.asmx where #### is the port number.)
  6. Click the Go button, and then click the Add Reference button when the Web Service is recognized.

To add a reference to a web service in Visual Studio

  1. From the Project menu, select Add Service Reference.
  2. In the Add Service Reference window that appears, type in the address of the virtual directory you created in the previous walkthrough. You can get the address by running the project from the previous walkthrough and copying the url from the address in the browser. (It will look something like http://localhost:####/DataSetWS/Service.asmx where #### is the port number.)
  3. Click the Go button, and then click the OK button when the Web Service is recognized.

To set the report data source to the one returned by the Web service

To set the report data source (for Visual Studio 2010 compatible with .NET Framework 2.0 Web service)

  1. Double-click the gray area below the report. This creates an event-handling method for the ReportStart event.
  2. Add code to the handler to use the web service dataset in the report.

    The following example shows what the code for the method looks like.

    To write the code in Visual Basic.NET

    Visual Basic.NET code. Paste INSIDE the ReportStart event
    Copy Code
    Dim ws As New localhost.Service
    Dim ds As DataSet()= ws.GetProduct()
    Me.DataSource = ds
    Me.DataMember = "Products"                                        
    

    To write the code in C#

    C# code. Paste INSIDE the ReportStart event.
    Copy Code
    localhost.DataSetWS ws = new localhost.Service;
    DataSet ds = ws.GetProduct();
    this.DataSource = ds;
    this.DataMember = "Products";                                        
    

To set the report data source

  1. Double-click the gray area below the report. This creates an event-handling method for the ReportStart event.
  2. Add code to the handler to use the web service dataset in the report.

    The following example shows what the code for the method looks like.

    To write the code in Visual Basic.NET

    Visual Basic.NET code. Paste INSIDE the ReportStart event.
    Copy Code
    Dim ws As New ServiceReference1.ServiceSoapClient()
    Dim ds As DataSet = ws.GetProduct()
    Me.DataSource = ds
    Me.DataMember = "Products"
    

    To write the code in C#

    C# code. Paste INSIDE the ReportStart event.
    Copy Code
    ServiceReference1.ServiceSoapClient ws = new ServiceReference1.ServiceSoapClient();
    DataSet ds = ws.GetProduct(); 
    this.DataSource = ds;
    this.DataMember = "Products";
    

To update the app.config file

Note: You need to update the app.config file if you added the Service Reference to the Visual Studio 2010 project in the previous section.
  1. In the Solution Explorer, open the app.config file.
  2. In the tag <binding name = "ServiceSoap"...>, set maxBufferSize and maxReceivedMessageSize to some large number, for example, 200500.
  3. In the next tag <readerQuotas...>, set maxArrayLength to some large number, for example, 60500.