SQL Connection String Provider Name

This is a more general question, I am building a report generator:

public ReportGenerator(IReportGeneratorConfig config)
{
    Configuration = config;
    ImagePaths = new Dictionary<string, string>();
    ReportErrors = new StringBuilder();

    DatabaseForReportQueries = DatabaseFactory.CreateDatabase(Configuration.DatabaseName);

    using (System.Data.Common.DbConnection conn = DatabaseForReportQueries.CreateConnection())
    {
        //get the connection string for use with the report directly.
        ReportConnectionString = conn.ConnectionString + "Provider=SQLOLEDB;";
        conn.Close();
    }
}

This is the error message that I get when I try to run the report button

Cannot open data source, please check ConnectionString and RecordSource properties. 
ConnectionString:   Database=Test80;Server=SQL01;uid=mcadmin;pwd=password;Provider=SQLOLEDB; 
RecordSource: 

All information is not corrupted separately from the Provider, which I send to my code. I do not know how to find out the name of the provider in the web application. This is not the same as tag providerNamein connectionStrings.config. It should beProvider=something;

The connection string has providerName = System.Data.SqlClient

+4
source share
2 answers

You do not need to provide the provider name in the connection string if you are using the .NET provider for SQL Server (System.Data.SqlClient).

Vendor names for .NET providers are implicit based on the implementation class and need not be specified in the connection string.

COM- OLE DB (SQLNCLI SQLOLEDB) ODBC SQL Server .NET, SqlClient.

SqlClient:

Data Source=SQL01;Initial Catalog=Test80;User Id=mcadmin;Password=password;
+3

SQL Server. Provider=SQLNCLI11. SQL Server ConnectionStrings.com

+1

All Articles