读取配置文件,获取连接字符串
<!-- 第一种 --> <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"]; -->
原文地址:https://www.cnblogs.com/zhaoyl9/p/11684189.html
时间: 2024-10-19 09:06:06