Connection String in ASP.Net with C#:
Web Config
<connectionStrings>
<add name="Master" connectionString="Data Source=10.155.44.11;Initial Catalog=Master;User Id=ta;Password=xxxxx" providerName="System.Data.SqlClient" />
</connectionStrings>
C# Coding:
public void setconnectionstring()
{
try
{
str = System.Configuration.ConfigurationManager.ConnectionStrings["Master"].ToString();
}
catch(Exception ex)
{
Response.Write(ex.ToString());
}
}
protected void Button1_Click(object sender, EventArgs e)
{
setconnectionstring();
SqlConnection con = new SqlConnection(str);
con.Open();
SqlCommand cmd = new SqlCommand("select * from phone_entries", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
con.close();
}