Glossary Item Box

Samples | Walkthroughs

See Also ActiveReports for .NET 2 Online Help Send feedback to Data Dynamics

Walkthrough: Modifying the Report Data Source at Run Time

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 (NWind.mdb).

Adding an ActiveReport to your project

To add an ActiveReport to your project

  1. Open a new project in Visual Studio.
  2. Click on Project > Add New Item.
  3. Select ActiveReports 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 on the yellow report DataSource icon in the Detail section. This brings up the report DataSource dialog box.
  2. Click on Build...
  3. Select "Microsoft Jet 4.0 OLE DB Provider" and click Next >>.
  4. Click on the ellipsis to browse for the access path to Nwind.mdb. 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

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 WinForm Viewer for help.

Samples | Walkthroughs

 

 


Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.