数据库配置类: 从配置文件web.config或app.config获得config对象 config对象中包含了DB类型和连接串的定义
Наследование: System.Configuration.ConfigurationSection
Пример #1
0
 /// <summary>
 /// 获得数据库配置对象
 /// </summary>
 /// <returns></returns>
 public static DBConfig GetDBConfig()
 {
     if (config == null)
     {
         config = (DBConfig)ConfigurationManager.GetSection("DBConfig");
     }
     return(config);
 }
Пример #2
0
 public static DBConfig GetDBConfig(string path, string dbType)
 {
     if (config == null)
     {
         ExeConfigurationFileMap ecfm = new ExeConfigurationFileMap();
         ecfm.ExeConfigFilename = path;
         Configuration cf = ConfigurationManager.OpenMappedExeConfiguration(ecfm, ConfigurationUserLevel.None);
         config = (DBConfig)cf.GetSection("DBConfig");
         DBType = cf.AppSettings.Settings[dbType].Value;
     }
     return(config);
 }
Пример #3
0
        public static DBConfig GetDBConfig(string path,string dbType)
        {
            if (config == null)
            {
                ExeConfigurationFileMap ecfm = new ExeConfigurationFileMap();
                ecfm.ExeConfigFilename = path;
                Configuration cf= ConfigurationManager.OpenMappedExeConfiguration(ecfm, ConfigurationUserLevel.None);
                config = (DBConfig)cf.GetSection("DBConfig");
                DBType = cf.AppSettings.Settings[dbType].Value;

            }
            return config;
        }
Пример #4
0
        /// <summary>
        /// 获得数据库配置对象
        /// </summary>
        /// <returns></returns>
        public static DBConfig GetDBConfig()
        {
            if (config == null)
            {
                config = (DBConfig)ConfigurationManager.GetSection("DBConfig");

            }
            return config;
        }