Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a connection string in my web app using c#
When i run the app, result this error: Keyword not supported: 'providername'.

C#
con.ConnectionString = " Data Source=; Initial Catalog=; User ID=; Password=; Trusted_Connection=Yes; providerName = System.Data.SqlClient";


What type of connection string shuold i use??
Posted
Comments
Mohd. Mukhtar 26-Nov-12 5:20am    
What data base you are using?
lovitaxxxx 26-Nov-12 5:34am    
sql database

1 solution

I am not sure it will works for you or not but I always use following code to get connection string..

C#
protected string ConnectionString
{
get
 {
 return WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
 }
}
using (var connection = new SqlConnection(ConnectionString))
    {
        connection.Open();

         ----------body----------

        connection.close();
    }  


Wherever you want connection string in web form use connection variable.
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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