Add connection using connectionStrings in web.config

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

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

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