Bind a Report to Data
The Report Designer is primarily designed to work with data-aware reports, meaning that a report obtains its general (dynamic) data from an external data source (most types of which are supported). This document describes how a newly created report can be bound to a data source.
The document consists of the following sections.
Bind a Report to a Database
To bind a report to a database, do the following.
- Create a new report.
-
Click its Smart Tag, and in the invoked actions list, expand the Data Source drop-down list and click Add New DataSource.
-
The first wizard page of the invoked Data Source Wizard allows you to specify what type of a data source you want to use. Select Database and click Next to proceed.
-
On the next page, specify the database to be used. If it is absent in the drop-down selector containing existing connections, select No, create a new connection and click Next.
Define a custom connection string, or select from the supported data source types. Depending on the data provider selected, it may be necessary to specify additional connection options (such as authentication type and database name) on this page.
-
If server authentication is required for the selected database type, the next page will prompt you to specify whether or not you want to save the user credentials along with the connection string.
Select the required option and click Next.
-
On the next page, you can construct an SQL query to obtain data from the database, or select a stored procedure.
To construct an SQL query, click Run Query Designer...
-
In the invoked Query Designer window, select an item from the list of available tables on the left and drop it onto the list of data tables to be used.
It is only possible to select a single table using the Query Designer. When creating a master-detail report, add the master table first.
-
Enable the check box near the added table to include all of its fields in the data view, and click OK to exit the Query Designer.
To assign a custom name to a data field, specify its Alias in the field list displayed below.
To manually customize an SQL string, enable the Allow SQL Editing option. Switching to this mode disables the visual features of the Query Designer, allowing you to directly edit the text of the SQL query.
Click OK to exit the Query Designer
Click Finish to exit the Data Source Wizard.
The newly created SQL data source will be displayed in the Components node of the Report Explorer.
Bind a Report to an Entity Framework Data Source
To bind a report to an Entity Framework data source, do the following.
- Create a new report.
-
Click its Smart Tag, and in the invoked actions list, expand the Data Source drop-down list and click Add New DataSource.
-
The first wizard page of the invoked Data Source Wizard allows you to specify what type of a data source you want to use. Select Entity Framework and click Next to proceed.
-
On the next page, select the required data context from the list of available data contexts and click Next.
-
Select a connection string to be used to establish data connection.
Click Next to proceed to the next page.
-
The next page prompts you to specify if you want to bind to a stored procedure.
To bind to a stored procedure, select it in the list of the available stored procedures and click Next
On the next page, configure the parameters to be passed to the selected stored procedure. Be sure to specify the correct parameter Type.
The newly created Entity Framework data source will be displayed in the Components node of the Report Explorer.