参考:http://www.dotblogs.com.tw/puma/archive/2010/01/25/aspnet-connectionstring-appsetting-file-configsource.aspx

原config文件

<connectionStrings>
<add name="eshop" connectionString="Data Source=(local);
Initial Catalog=tempdb;User ID=sa;"
providerName="System.Data.SqlClient"/>
</connectionStrings>

 

  修改后

  <connectionStrings configSource ="dbConnection.config" />

 

dbConnection.config文件

 

代码
<?xml version="1.0" encoding="utf-8"?>
<connectionStrings>
<clear />
<add name="eshop" connectionString="Data Source=(local);
Initial Catalog=tempdb;User ID=sa;"
providerName="System.Data.SqlClient"/>
</connectionStrings>

 

 

 appSettings 类似

<appSettings configSource="settings.config" />

 

<?xml version="1.0" encoding="utf-8"?>
<appSettings>
  <add key="Blog" value="F6 Team" />
  <add key="Name" value="puma" />
  <add key="skill" value="ASP.NET" />
</appSettings>

 

 <appSettings file="settings.config">
    <add key="Blog" value="F6 Team" />
    <add key="Name" value="puma" />
  </appSettings>

 

<?xml version="1.0" encoding="utf-8"?>
<appSettings>
  <add key="skill" value="ASP.NET" />
</appSettings>

 

 

 

 

 

posted on 2010-12-06 20:33  佐伊凡  阅读(755)  评论(0编辑  收藏  举报