Tutorial 1 - Bind a Report to Data
- 3 minutes to read
This tutorial explains how to bind a report to an SQLite database. Before you begin this tutorial, create a new Visual Studio project and add a blank report to this project. Refer to the following topic for instructions: Create a Report in Visual Studio.
Note
You should install the System.Data.SQLite or Microsoft.Data.SQLite NuGet package to be able to connect to an SQLite database in your project. Note that you should also rebuild your project after you install the package.
Bind a Report to an SQLite Database
Invoke the Data Source Wizard
Click the report’s smart tag. In the invoked Report Tasks menu, expand the Data Source property’s drop-down list and click Add Report Data Source.
Select Data Connection Type
Select SQLite in the invoked Data Source Wizard and click Next.
Choose Whether to Use an Existing Connection
On the next Data Source Wizard page, select the No, I’d like to specify the connection parameters myself option and click Next.
Specify Connection Properties
Specify connection properties. Assign the path to the Northwind database to the Database option. You can find this database in the folder that includes DevExpress demos:
C:\Users\Public\Documents\DevExpress Demos 24.1\Components\Data\nwind.db
Click Next.
Choose Whether to Save a Connection String
On the next page, enable the Yes, save the connection string as option if you want to save the connection string to your project configuration file. Then, click Next.
Select a View
Choose all fields from the OrderDetailsExtended view and click Finish.
Tip
In addition to views, you can also select tables, stored procedures, or create custom queries to retrieve data from SQL databases. See the following topics for more information:
Display Data from the Data Source in a Report
A data source that contains the OrderDetailsExtended view appears in the Field List.
To display data from a data source in your report, do the following:
- Assign the data source to the report’s DataSource property.
- Set the report’s DataMember property to the data source’s collection from which you want to retrieve data.
If you add a new data source, the Report Designer specifies (changes) these properties automatically. In our case, the report’s DataSource and DataMember properties are set to the added SQL data source and the chosen OrderDetailsExtended view, respectively.
Summary
This tutorial explained in detail how to bind a report to an SQLite database. Refer to the following tutorial on how to display data from a database and use the data to design the report layout: Tutorial 2 - Design the Report Layout.
In addition to SQL databases, you can also bind a report to a business object, JSON file, MongoDB database, and other data sources. See the following documentation section for more information: Bind Reports to Data.
Also, you can bind your report not only to one data source or view (table), but to multiple data sources and different tables of one data source. Moreover, you can combine multiple data sources into one. Refer to the following topics for more information: