Skip to content

Latest commit

 

History

History
76 lines (59 loc) · 5.54 KB

File metadata and controls

76 lines (59 loc) · 5.54 KB
title Using the Microsoft SQL Client Data Provider
page_title Integrating the Microsoft SQL Client Data Provider
description Learn more about how the Microsoft SQL Client data provider can be used by the SqlDataSource component to connect to MS SQL databases in Telerik Reporting.
slug telerikreporting/designing-reports/connecting-to-data/data-source-components/sqldatasource-component/using-data-providers/using-microsfost-data-sqlclient-data-provider
tags Microsoft.Data.SqlClient,data,provider
published true
position 4
reportingArea General

Using Microsoft.Data.SqlClient in Reporting

The Microsoft.Data.SqlClient namespace is essentially a new version of the System.Data.SqlClient namespace and can thus be used for connecting to Microsoft SQL Databases.

Setting up the Microsoft.Data.SqlClient Data Provider in the .NET Standalone Report Designer

  1. Create a new .NET 8 Console Application project.
  2. Install the Microsoft.Data.SqlClient NuGet package to it and build the project.
  3. Navigate to the bin/Debug/net8.0 subdirectory of the project, and copy all assemblies there except for the assembly with the name of the project.
  4. Paste the assemblies in the .NET Standalone Report Designer installation directory e.g. C:\Program Files (x86)\Progress\Telerik Reporting {{site.suiteversion}}\Report Designer\.NET.
  5. The bin/Debug/net8.0 folder of the console application should contain an additional folder named runtimes with several subfolders such as win, unix, win-x64, etc. Copy the DLLs from the folders that correspond to your Operating System and CPU architecture.
  6. Paste the additional runtime assemblies in the .NET Standalone Report Designer installation directory e.g. C:\Program Files (x86)\Progress\Telerik Reporting {{site.suiteversion}}\Report Designer\.NET.
  7. Restart the designer if you have previously opened it.
  8. Add a new SQL DataSource and you should see that the Microsoft.Data.SqlClient Data Provider is in the dropdown.

Setting up the Microsoft.Data.SqlClient Data Provider in .NET Applications

.NET Application with the Web Report Designer

  1. Install the Microsoft.Data.SqlClient NuGet package to it and build the project.

  2. Register the SqlClientFactory.Instance in the Telerik.Reporting.Processing.Data.DbProviderFactories using the RegisterFactory method within the static constructor of the controller that inherits from ReportDesignerControllerBase. For example:

    {{source=CodeSnippets\Blazor\Docs\Controllers\ReportDesignerControllerMicrosoftDataSqlClient.cs region=NET_Application_with_the_Web_Report_Designer}}

  3. If the SqlDataSource component uses a shared connection where it is retrieved from the configuration file of the project(e.g. appsettings.json), the provider name must be specified in the connection. For example:

    {
    "ConnectionStrings":{
    	"mssql":
    		{
    			"connectionString":"Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;",
    			"providerName":"Microsoft.Data.SqlClient"
    		}
    	}
    }

.NET Application with Web Report Viewer

  1. Install the Microsoft.Data.SqlClient NuGet package to it and build the project.

  2. Register the SqlClientFactory.Instance in the Telerik.Reporting.Processing.Data.DbProviderFactories using the RegisterFactory method within the static constructor of the controller that inherits from ReportsControllerBase. For example:

    {{source=CodeSnippets\Blazor\Docs\Controllers\ReportsControllerMicrosoftDataSqlClient.cs region=NET_Application_with_Web_Report_Viewer}}

  3. If the SqlDataSource component uses a shared connection where it is retrieved from the configuration file of the project(e.g. appsettings.json), the provider name must be specified in the connection. For example:

    {
    	"ConnectionStrings":{
    		"mssql":
    		{
    			"connectionString":"Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;",
    			"providerName":"Microsoft.Data.SqlClient"
    		}
    	}
    }

See Also