Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends..
I have a windows application and have its app.config file in which I added connection string named 'Con'. I am using sql server 2005 enterprise edition and visual studio 2008 professional.

The app.config file is as follows.

XML
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
    </configSections>
    <connectionStrings>
        <add name="Con" connectionString="Data Source=JASIL;User ID=sa;Initial Catalog=Lab_DB"
             providerName="System.Data.OleDb"/>
    </connectionStrings>
</configuration>




and i used the following code to retrieve the connection string

Dbcon = new SqlConnection(ConfigurationManager.ConnectionStrings["Con"].ConnectionString);

but it caused the error - An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'.

then i changed it to


XML
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
    </configSections>
    <connectionStrings>
        <add name="Con" connectionString="Provider=SQLOLEDB.1;Data Source=JASIL;User ID=sa;Initial Catalog=Lab_DB"
             providerName="SQLOLEDB.1"/>
    </connectionStrings>
</configuration>


the it shows the error - Keyword not supported: 'provider'.


I dont know what is the error .. Please help me...
Thank You.
Posted

1 solution

this site always saves my skin:

http://www.connectionstrings.com/sql-server-2005#p1
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900