Add this in web.config file,
<add name="sqlConn" connectionString="server='servername';Initial Catalog='dbname';user id='userid';password='password';Connection Timeout=0;"/>
Then in code use the below code,
public SqlConnection sqlCon;
sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings("sqlConn").ConnectionString);