Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3138
  • Last Modified:

An OLE DB Provider was not specified in the ConnectionString. 'Provider=SQLOLEDB;

Hi Experts,
i trying to run query using C#, i am getting the following problem

An OLE DB Provider was not specified in the ConnectionString.  An example would be, 'Provider=SQLOLEDB;'

string strConString = System.Configuration.ConfigurationManager.ConnectionStrings["WorkflowConnStr"].ConnectionString.ToString();
    
        string sqlstr = "select * from table" 
        
        OleDbConnection myConnection = new OleDbConnection(strConString);

         try
             {myConnection.Open();}
         catch (Exception err) 
              { System.Diagnostics.Debug.WriteLine(err.Message); }

        OleDbCommand myCommand = new OleDbCommand(sqlstr, myConnection);
        OleDbDataReader reader = myCommand.ExecuteReader();

Open in new window


web.cofig
  <connectionStrings>
  <add name="WorkflowConnStr" connectionString="Data Source=MOFSQL08R2-PROD;Initial Catalog=Workflow;user id=AdobeLCES2_User;password=WFProd2010" providerName="System.Data.OleDb.OleDbConnection"  />
  </connectionStrings>

Open in new window


any suggestion ?
0
AZZA-KHAMEES
Asked:
AZZA-KHAMEES
1 Solution
 
Koen Van WielinkIT ConsultantCommented:
Have you tried removing the "providerName=....." portion from the web.config?
0
 
AZZA-KHAMEESAuthor Commented:
yes tried that but still the same error
0
 
Carl TawnSystems and Integration DeveloperCommented:
It means what it says; you haven't specified what OLE DB provider to use. If it's a SQL Server it would be SQLOLEDB.1, as in:
  <connectionStrings>
  <add name="WorkflowConnStr" connectionString="Provider=SQLOLEDB.1;Data Source=MOFSQL08R2-PROD;Initial Catalog=Workflow;user id=AdobeLCES2_User;password=WFProd2010" providerName="System.Data.OleDb.OleDbConnection"  />
  </connectionStrings>

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
ste5anSenior DeveloperCommented:
Looks like you're connecting to a SQL Server, so why do you use OleDbCommand instead of SqlCommand?

See also Store connection string in web.config.
0
 
AZZA-KHAMEESAuthor Commented:
thank you all for the replies
solved the issues by adding Provider=SQLNCLI11 to the connection string

<add name="WorkflowConnStr" connectionString="Data Source=Server;Initial Catalog=DBName;user id=usr;password=password;Provider=SQLNCLI11" providerName="System.Data.OleDb.OleDbConnection"/>

Open in new window

0
 
Koen Van WielinkIT ConsultantCommented:
Shouldn't points be awarded to Carl? He basically gave the answer.
0
 
AZZA-KHAMEESAuthor Commented:
found solution from different forum
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now