动态修改微软企业库的连接字符串

            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);



            ConfigurationSection connectionConfigurationSection = config.Sections["connectionStrings"];

            ConnectionStringsSection connectionStringsSection = connectionConfigurationSection as ConnectionStringsSection;

            connectionStringsSection.ConnectionStrings["dataSource"].ConnectionString = ConStr;

            config.Save();

            ConfigurationManager.RefreshSection("connectionStrings");



            if (DataKey == null)

            {

                db = DatabaseFactory.CreateDatabase();

            }

            else

            {

                db = DatabaseFactory.CreateDatabase(DataKey);

         

            }

 

你可能感兴趣的:(字符串)