Web.config和App.config配置连接字符串
读取配置文件,获取连接字符串
<!-- 第一种 -->
<connectionStrings>
<add name="connString" connectionString="server=.;uid=sa; pwd=123456; database=SchoolDB;"/>
</connectionStrings>
<!-- string connString = System.Configuration.ConfigurationManager.ConnectionStrings["connString"].ToString(); -->
<!-- 第二种 -->
<appSettings>
<add key="connString" value="server=.;uid=sa; pwd=123456; database=SchoolDB;"/>
</appSettings>
<!-- string connString = System.Configuration.ConfigurationManager.AppSettings["connString"]; -->