Solved

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

Posted on 2014-04-20
7
2,788 Views
Last Modified: 2014-04-26
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
Comment
Question by:AZZA-KHAMEES
7 Comments
 
LVL 13

Expert Comment

by:Koen Van Wielink
ID: 40012084
Have you tried removing the "providerName=....." portion from the web.config?
0
 

Author Comment

by:AZZA-KHAMEES
ID: 40012087
yes tried that but still the same error
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 40012311
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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 33

Expert Comment

by:ste5an
ID: 40012313
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
 

Accepted Solution

by:
AZZA-KHAMEES earned 0 total points
ID: 40012332
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
 
LVL 13

Expert Comment

by:Koen Van Wielink
ID: 40014092
Shouldn't points be awarded to Carl? He basically gave the answer.
0
 

Author Closing Comment

by:AZZA-KHAMEES
ID: 40024362
found solution from different forum
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question