New to Telerik Reporting? Download free 30-day trial
You can connect to a Microsoft SQL Server database using the Telerik SqlDataSource component. To do this, you need a connection string and access rights to a SQL Server database. Then, you can use the SqlDataSource component to provide data to data items (Report, Table, Chart).
In Microsoft Visual Studio, open a Telerik Report. From the Telerik Reporting R3 2021 group in the Toolbox, select the SqlDataSource component and click on the design surface to add it to the Report.
Choose your Data Connection dialog box appears.
Click New Connection
- If the Change Data Source dialog box appears, click Microsoft SQL Server, and then click Continue.
In the Add Connection dialog box, click Change.
In the Change Data Source dialog box, click Microsoft SQL Server, and then click OK.
In the Server name box, enter the name for your SQL Server database, and then under Logon to the server, enter the logon credentials.
For the logon credentials, select the option that is appropriate for accessing and running the SQL Server database (either by using Microsoft Windows integrated security or by providing a specific ID and password) and, if it is required, enter a user name and password.
In the Select or enter a database name list, enter a valid database on the server e.g. AdventureWorks.
Optionally, click Test connection to verify that your connection works.
Click OK, Click Next to continue and select Yes, save this connection…. Enter a name for your connection for when it is stored in the application configuration file, and then click Next.
Select the stored procedure from which to retrieve results e.g. uspGetEmployeeManagers and click Next.
If the stored procedure has a parameter, the Configure Data Source Parameters step shows. You can leave the sql parameter value blank and continue, create an expression or create a report parameter as values. Choosing the last option would give you ability to use the built-in report parameters to specify value at run time. The SqlDataSource component submits the text in the SelectCommand property to the database, and the database returns the result of the stored procedure back to the SqlDataSource component. Any data items that are bound to the data source component would display the result set on your report.
To test your query, click Next, and then click Execute Query.
Click Finish. The Wizard would close and the SqlDataSource component would be ready for use by the data items.