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;