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
March 25, 2025

How to Merge Multiple Reports into One in FastReport .NET

FastReport .NET is a powerful tool for creating and managing reports. In this article, we will look at how to combine multiple reports into one in FastReport .NET.
March 11, 2025

How to Use FastReport .NET Avalonia on Fedora Workstation with Wayland Protocol

In this article, we will discuss how to run FastReport .NET Avalonia on the "Fedora Workstation 39" operating system with Wayland protocol.
March 07, 2025

How to Create a QR Code with an Image in FastReport .NET

The article figured out how to insert a picture into a QR Code from the report designer FastReport.NET in just a couple of clicks.
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.