标签:
添加参数配置文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
<add key="FactoryName" value="GDSFactory"/>
</appSettings>
</configuration>
调用:
添加using System.Configuration;引用
string factoryName = ConfigurationManager.AppSettings["FactoryName"];
进行添加
2.添加数据库链接文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<connectionStrings>
<add name="connstr" connectionString="server=.;database=SchoolIDB;uid=sa;pwd=123"/>
</connectionStrings>
</configuration>
调用
添加using System.Configuration;引用
private static readonly string connString = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
标签:
原文地址:http://www.cnblogs.com/liyiyong/p/5152571.html