How to use internal data source in a FastReport .NET report

2016-02-24

If you create a report along with the client application, it is logical to create a single source of data in a program and use it in many reports.

This article will focus on the connection of the report FastReport .NET applications to the data source.

It is best to demonstrate the process by an example. Create application Windows Forms. Add the data source to the program. In my case - the database xml.

 

Now add a dataset component to the form from the toolbox. Select the typed dataset.

 

All that's left to do is to create a report and register the data source in it.

Add a button and the Report component from the toolbar.

Double-click on the component report1 to open the report designer. But first, choose a data source applications:

 

Create a simple report with the list in the designer:

 

The list of available data sources can be seen by clicking on the icon (highlighted in red):

 

The window appears:

 

Save the report and return to the application. Add the button click event handler:

1
2
3
4
5
6
 private void button1_Click(object sender, EventArgs e)
 {
 report1.Load(Environment.CurrentDirectory + "/Report.frx");
 report1.RegisterData(demoDataSet1);
 report1.Show();
 }

 Do not forget to add the FastReport library in using. Here we load the report file. Then, register the data source in the report. And run a report in preview mode.

 

RegisterData function allows you to register: DataSet, DataTable, DataView, DataRelation, IEnumerable. The latter one may be a list of objects (including any embedded objects) or, for example, the result of LINQ query. It is important to register the data in the report after loading the report and before viewing or exporting.

Using a data source from the application, it allows us to avoid the need to create a database connection in each report. Besides, if it necessary to change the settings you need edit one connection only.

August 12, 2024

How to build and install the Postgres plugin in FastReport .NET

This article describes how to connect to the database using the FastReport .NET plugin for the report designer from Visual Studio via the NuGet server.
August 08, 2024

How to install FastReport .NET and its components on Windows

Step-by-step instructions for online and manual installation via the FastReport registration code.NET and its components in Windows.
July 26, 2024

Updating HTMLObject as a plugin for FastReport .NET

Detailed instructions for using the new HTMLObject plugin, which uses splitting DOM HTML into FastReport report objects.
Fast Reports
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314

© 1998-2024 Fast Reports Inc.