Connectionstring in web.config file and call from asp.net

Quote

we add connection string in web.config file.

<connectionStrings>
<add name=”LocalSqlServer” connectionString=”data source=.\SQLEXPRESS; Initial Catelog=”example” Integrated Security=true” providerName=”System.Data.SqlClient”   />
</connectionStrings>

From web.config file call the connectionstring

uisng system.configuration;

using system.Data.SqlClient;

string connectionString=ConfigurationManager.ConnetionStrings[“Name of Connection”].ConnectionSrting;

sqlConnection con=new SqlConnection(ConnectionString);