ActiveReports for .NET 3 Online Help Request technical support
DataSet Web Service
See Also
User Guide > Samples and Walkthroughs > Walkthroughs > Standard Edition Walkthroughs > Advanced > Web Walkthroughs (Standard Edition) > Web Services Walkthroughs > DataSet Web Service

Glossary Item Box

With ASP.NET, it is easy to set up a Web Service that returns a dataset which you can use as a data source for an ActiveReport.

This walkthrough illustrates how to create a simple Web Service that returns a dataset.

This walkthrough is split up into the following activities:

To complete the walkthrough, you must have access to the Northwind database.
A copy is located at C:\Program Files\Data Dynamics\ActiveReports for .NET 3.0\Data\NWIND.MDB.

When you have completed this walkthrough, you will have created a Web Service that returns a dataset which can be used as a data source for an ActiveReport.

Creating an ASP.NET Web Service project

To create an ASP.NET Web Service project in Visual Studio 2003

  1. From the File menu, select New > Project.
  2. In the Templates window of the New Project dialog, select ASP.NET Web Service.
  3. Change the name of the project from WebService1 to DataSetWS.
  4. Click OK to open the new project in Visual Studio. 

To create an ASP.NET Web Service project in Visual Studio 2005

  1. From the File menu, select New > Web Site.
  2. In the Templates window of the New Web Site dialog, select ASP.NET Web Service.
  3. Change the name of the project from WebService1 to DataSetWS.
  4. Click OK to open the new project in Visual Studio.

Adding code to create the Web Method

To write the code to create the Web Method

'Visual Basic
Private connString As String
'Change your data source path as needed
<WebMethod(Description:="Returns a DataSet containing all Products")> _
Public Function GetProduct() As Data.DataSet
  connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Data Dynamics\ActiveReports for .NET 3.0\Data"
  Dim adapter As New Data.OleDb.OleDbDataAdapter("select * from products", connString)
  Dim ds As New Data.DataSet()
  adapter.Fill(ds, "Products")
  Return ds
End Function

//C#
//Change your data source path as needed
private static string connString = "Provider=Microsoft.Jet.OLEDB.4.0;C:\Program Files\Data Dynamics\ActiveReports for .NET 3.0\Data";
[WebMethod(Description="Returns a DataSet containing all Products")]
public Data.DataSet GetProduct()
{
   Data.OleDb.OleDbDataAdapter adapter;
   Data.DataSet ds;
   adapter = new Data.OleDb.OleDbDataAdapter("select * from products", connString);
   ds = new Data.DataSet();
   adapter.Fill(ds, "Products");
   return ds;
}

Testing the Web Service

To test the Web Service

  1. Press F5 to run the project. 
  2. Click "GetProduct" in the list of supported operations.
  3. Click the Invoke button to test the Web Service operation.
  4. If the test is successful, you will see a valid XML schema of the Northwind products table.

Publishing the Web Service

To publish the Web Service

  1. In the Solution Explorer, right-click the project name and select Publish Web Site
  2. Click the OK button.
  3. This makes the Web Service available for consumption by other projects.

See Also

©2009. All Rights Reserved.