ActiveReports for .NET 3 Online Help Request technical support
Walkthrough: Modifying the Report Data Source at Run Time
See Also
User Guide > Samples and Walkthroughs > Walkthroughs > Standard Edition Walkthroughs > Advanced > Run-Time Reporting Walkthroughs > Walkthrough: Modifying the Report Data Source at Run Time

Glossary Item Box

ActiveReports allows you to change the data source of a report at run time based on the location of the sample database file on the user's computer.

This walkthrough illustrates how to set up a report to set a report's data source at run time.

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.

Adding an ActiveReport to your project

To add an ActiveReport to your project

  1. Open a new project in Visual Studio.
  2. From the Project menu, select Add New Item.
  3. Select ActiveReports 3.0 File and rename the file rptModifyDS.
  4. Click Open.

Connecting the data source to a database

To connect the data source to a database

  1. Click the gray report DataSource icon in the Detail section to open the report DataSource dialog.
  2. Click Build.
  3. Select "Microsoft Jet 4.0 OLE DB Provider" and click Next.
  4. Click the ellipsis button to browse for the access path to the Northwind database. Click Open once you have selected the appropriate access path.
  5. Click OK to continue.
  6. In the Query field, type "Select * from products".
  7. Click OK to return to the report design surface.

Adding controls to contain data

To add controls to the report

Adding code to set the database path

To write the code in Visual Basic

To write the code in C#

Adding code to the ReportStart event

To write the code in Visual Basic or C#

Adding code to the ReportEnd event 

To write the code in Visual Basic

To write the code in C#

Viewing the report

To view the report

  1. Add the ActiveReports viewer control to a Windows Form.
  2. Add the code needed to set the viewer document equal to the report document. See Using the ActiveReports Windows Form Viewer for help.
You can quickly view your report at design time by clicking the Preview tab at the bottom of the designer.

See Also

©2009. All Rights Reserved.