<
appSettings
>
< add key = " DBConnString " value = " server=.;User ID=sa;Password=;database=news1 ; " />
< add key = " EntityPath " value = " ~/EntityDefine/ " />
< add key = " DBType " value = " sqlserver " />
< add key = " CachedConn " value = " 4 " />
< add key = " UFServer " value = " 192.168.0.213 " />
< add key = " UFUser " value = " sa " />
< add key = " UFPwd " value = "" />
</ appSettings >
< add key = " DBConnString " value = " server=.;User ID=sa;Password=;database=news1 ; " />
< add key = " EntityPath " value = " ~/EntityDefine/ " />
< add key = " DBType " value = " sqlserver " />
< add key = " CachedConn " value = " 4 " />
< add key = " UFServer " value = " 192.168.0.213 " />
< add key = " UFUser " value = " sa " />
< add key = " UFPwd " value = "" />
</ appSettings >
其次在Global.asax中Application_Start加入
IAppConfigSetter setter
=
new
AppConfigSetter();
ApplicationConfiguration.SetAppConfiguration(setter);
ApplicationConfiguration.SetAppConfiguration(setter);
是为了生成配置文件
再次建立以个类AppConfigSetter.cs
public
class
AppConfigSetter :System.Web.UI.Page, IAppConfigSetter
{
//得到当前数据连接
public string GetDBConnectionString ()
{
return ConfigurationSettings.AppSettings["DBConnString"];
}
public string GetDBType()
{
return ConfigurationSettings.AppSettings["DBType"];
}
//得到实体定义XML文件的路径
public string GetEntityDefinitionPath()
{
return Server.MapPath(ConfigurationSettings.AppSettings["EntityPath"]);
}
//得到连接池的大小
public int GetPooledConnectionCount()
{
return int.Parse(ConfigurationSettings.AppSettings["CachedConn"]);
}
// //得到其他数据库连接
public NameValueCollection GetOtherCollections()
{
return ConfigurationSettings.AppSettings;
// return (new test_websharp.ZTConfigDB()).GetZT();
}
}
这样它的基础配置就完成了。
{
//得到当前数据连接
public string GetDBConnectionString ()
{
return ConfigurationSettings.AppSettings["DBConnString"];
}
public string GetDBType()
{
return ConfigurationSettings.AppSettings["DBType"];
}
//得到实体定义XML文件的路径
public string GetEntityDefinitionPath()
{
return Server.MapPath(ConfigurationSettings.AppSettings["EntityPath"]);
}
//得到连接池的大小
public int GetPooledConnectionCount()
{
return int.Parse(ConfigurationSettings.AppSettings["CachedConn"]);
}
// //得到其他数据库连接
public NameValueCollection GetOtherCollections()
{
return ConfigurationSettings.AppSettings;
// return (new test_websharp.ZTConfigDB()).GetZT();
}
}