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.

.NET .NET FastReport FastReport
February 20, 2025

Using Dot Matrix Printers for Printing Receipts

This article will explore how to integrate a dot matrix printer into the process of creating and outputting reports using FastReport .NET.
February 17, 2025

Adding New Users to FastReport Cloud

In the Business edition of the FastReport Cloud service, you can add users to a single workspace for simultaneous collaboration.
February 10, 2025

How to Try FastReport .NET WEB Before Purchase

By testing the WEB pack before purchasing, you can make an informed choice about whether FastReport is suitable for you.NET for your tasks.
Fast Reports
  • 800-985-8986 (English, US)
  • +31 97 01025-8466 (English, EU)
  • +49 30 56837-3928 (German, DE)
  • +55 19 98147-8148 (Portuguese, BR)
  • info@fast-report.com
  • 66 Canal Center Plaza, Ste 505, Alexandria, VA 22314

© 1998-2025 Fast Reports Inc.