惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
宝玉的分享
宝玉的分享
博客园 - 【当耐特】
有赞技术团队
有赞技术团队
G
Google Developers Blog
Microsoft Security Blog
Microsoft Security Blog
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
Blog — PlanetScale
Blog — PlanetScale
博客园_首页
L
LangChain Blog
Stack Overflow Blog
Stack Overflow Blog
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
罗磊的独立博客
T
Tailwind CSS Blog
博客园 - 叶小钗
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
博客园 - 聂微东
博客园 - Franky
B
Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
F
Fortinet All Blogs

博客园 - DingJun

Javascript 继承方法3 Javascript 继承方法2 Javascript 继承方法1 Call web service from excel Cannot load type (加载页面出错) 几个主流的浏览器引擎及判定 防止数据库日志文件增长 配置发布数据库服务器时碰到错误18483 一些有关。NET界面处理与多线程的文章 不可恢复的生成错误 在.Net安装项目中如何判断操作系统的版本 SQL Server 使用外部连接 在.NET下利用目录服务操纵本机用户和用户组 System.windows.forms.datagrid控件使用技巧 读取配置文件中的自定义节 区域设置与格式化(1) 默认的 IIS MIME 类型关联 在.NET中使用XPath查找指定元素时遇到的麻烦(以dataConfiguration.config为例) 使用Data access block
修改dataConfiguration.config文件
DingJun · 2005-08-12 · via 博客园 - DingJun

示例代码:

/*
            using Microsoft.Practices.EnterpriseLibrary.Configuration;
            using Microsoft.Practices.EnterpriseLibrary.Common;
            using Microsoft.Practices.EnterpriseLibrary.Data;
            using Microsoft.Practices.EnterpriseLibrary.Data.Configuration;
            
*/


            DatabaseSettings dbSetting 
= ConfigurationManager.GetConfiguration("dataConfiguration"as DatabaseSettings;
            ConnectionStringData defaultConnection 
= dbSetting.ConnectionStrings[0];
            MessageBox.Show(defaultConnection.Parameters[
"database"].Value);
            defaultConnection.Parameters[
"Integrated Security"].Value = "True";
            defaultConnection.Parameters[
"database"].Value = "111";
            defaultConnection.Parameters[
"server"].Value = "45345";
            ConfigurationManager.WriteConfiguration(
"dataConfiguration", defaultConnection);

App.config/Web.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    
<configSections>
        
<section name="enterpriselibrary.configurationSettings" type="Microsoft.Practices.EnterpriseLibrary.Configuration.ConfigurationManagerSectionHandler, Microsoft.Practices.EnterpriseLibrary.Configuration" />
        
<section name="exceptionManagement" type="Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManagerSectionHandler,
                   Microsoft.ApplicationBlocks.ExceptionManagement"
/>
        
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
    
</configSections>
    
<enterpriselibrary.configurationSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" defaultSection="" applicationName="Application" xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/configuration">
    
<configurationSections>
        
<configurationSection name="dataConfiguration" encrypt="false">
        
<storageProvider xsi:type="XmlFileStorageProviderData" name="XML File Storage Provider" path="dataConfiguration.config" />
        
<dataTransformer xsi:type="XmlSerializerTransformerData" name="Xml Serializer Transformer">
            
<includeTypes />
        
</dataTransformer>
    
</configurationSection>
    
</configurationSections>
    
<keyAlgorithmStorageProvider xsi:nil="true" />
    
</enterpriselibrary.configurationSettings>    
</configuration>

posted on 2005-08-12 18:49  DingJun  阅读(2735)  评论(3)    收藏  举报