Skip to main content
A newer version of this page is available. .

Bind a Report to a Stored Procedure

  • 2 minutes to read

This tutorial demonstrates how to bind a report to a stored procedure provided by an SQL data source.

To bind to a stored procedure, do the following.

  1. Click the report’s smart tag. In the invoked actions list, expand the drop-down menu for the DataSource property and click Add Report Data Source…

    how-to-ef-datasource01

    Note

    The Data Source Wizard is more appropriate for binding a report to a stored procedure than the Report Wizard, because the last one does not provide the possibility to specify dynamic values for the procedure’s parameter. Thus, create an empty report and run the Data Source Wizard to bind the report to a stored procedure and specify a data source for procedure parameters.

  2. On the first page of the invoked Data Source Wizard, select Database and click Next.

    ReportWizard-SelectDataSourceType

  3. The next page allows you to specify whether you want to use an existing data connection or create a new data connection with custom parameters. Select the first option to create a new connection and click Next.

    data-source-wizard-specify-data-connection

  4. On the next page, you can define a custom connection string or select from the list of supported data providers. 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.

    how-to-stored-procedure-select-database

    To proceed to the next wizard page, click Next.

  5. Click Next on the following page to save the created connection string to the configuration file.

    data-source-wizard-mssqlserver-save-connection

  6. On the next page, you can choose which tables, views and/or stored procedures to add to the report. Expand the Stored Procedures category, select the required stored procedure from the list of available stored procedures and click Next.

    how-to-stored-procedure-select-procedure

  7. Then the wizard generates query parameters for each stored procedure parameter. The next wizard page presents the generated query parameters. You can assign a static value or an expression to a parameter. In addition, you can map a report parameter to a query parameter. This is helpful when end users specify parameter values in the report’s Preview. For details on how to configure query parameters, refer to the Query Parameters topic.

    Click the Preview button and select a query to preview the result of the stored procedure execution with the specified parameters.

    how-to-stored-procedure-specify-parameters

    The following image demonstrates the Data Preview displaying the resulting data sample. Click Close to exit the preview.

    how-to-stored-procedure-preview-data

    Click Finish to exit the wizard.

See Also