在webconfig里面有两种写法
<connectionStrings><add name="Sql2005Express" connectionString="Data Source=.\SQLEXPRESS;AttachDbFileName=|DataDirectory|NorthWnd.mdf;Integrated Security=True;User Instance=true" providerName="System.Data.SqlClient"/>
</connectionStrings>
程序中:ConfigurationManager.ConnectionStrings["Sql2005Express"].ConnectionString;
<appSettings><add name="Sql2005Express" connectionString="Data Source=.\SQLEXPRESS;AttachDbFileName=|DataDirectory|NorthWnd.mdf;Integrated Security=True;User Instance=true" providerName="System.Data.SqlClient"/>
</appSettings>
程序中:ConfigurationManager.AppSettings["sql2005express"].ToString();