Add connection using connectionStrings in web.config

Ranjeet_8
Posted by Ranjeet_8 under ASP.NET category on | Points: 40 | Views : 2032
Add this code in web.config

<connectionStrings>
<add name="ConnectionStringName" connectionString="Data Source=localhost;Initial Catalog=DataBaseName;User ID=SQLUserID;password=SQLPassword;" providerName="System.Data.SqlClient" />
</connectionStrings>

How to read connection string in c#

string ConStr=ConfigurationManager.ConnectionStrings["ConnectionStringName"].ConnectionString;

Comments or Responses

Posted by: T.Saravanan on: 9/3/2012 Level:Silver | Status: [Member] [MVP] | Points: 10
What is difference between appSettings and connectionStrings using in web.config?

Login to post response