其实,很简单只好把数据层或逻辑层的配置文件“合并”到表示层的配置文件(app.config或web.conifg)中即可。
例如:
数据层的配置文件(app.config)如下:







Persist Security Info=True;Jet OLEDB:Database Password=123"



1
<?xml version="1.0"?>
2
<!--
3
注意: 除了手动编辑此文件以外,您还可以使用
4
Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
5
“网站”->“Asp.Net 配置”选项。
6
设置和注释的完整列表在
7
machine.config.comments 中,该文件通常位于
8
\Windows\Microsoft.Net\Framework\v2.x\Config 中
9
-->
10
<configuration>
11
<appSettings/>
12
<system.web>
13
<!--
14
设置 compilation debug="true" 将调试符号插入
15
已编译的页面中。但由于这会
16
影响性能,因此只在开发过程中将此值
17
设置为 true。
18
-->
19
<compilation debug="true"/>
20
<!--
21
通过 <authentication> 节可以配置 ASP.NET 使用的
22
安全身份验证模式,
23
以标识传入的用户。
24
-->
25
<authentication mode="Windows"/>
26
<!--
27
如果在执行请求的过程中出现未处理的错误,
28
则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
29
开发人员通过该节可以配置
30
要显示的 html 错误页
31
以代替错误堆栈跟踪。
32
33
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
34
<error statusCode="403" redirect="NoAccess.htm" />
35
<error statusCode="404" redirect="FileNotFound.htm" />
36
</customErrors>
37
-->
38
</system.web>
39
</configuration>

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

合并后的表示层的配置文件(web.config)如下:
1
<?xml version="1.0"?>
2
<!--
3
注意: 除了手动编辑此文件以外,您还可以使用
4
Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
5
“网站”->“Asp.Net 配置”选项。
6
设置和注释的完整列表在
7
machine.config.comments 中,该文件通常位于
8
\Windows\Microsoft.Net\Framework\v2.x\Config 中
9
-->
10
<configuration>
11
<appSettings/>
12
<connectionStrings>
13
<add name="anjou.DataAccess.Properties.Settings.anjouConnectionString"
14
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\App_Data\db1.mdb;
Persist Security Info=True;Jet OLEDB:Database Password=123"
15
providerName="System.Data.OleDb" />
16
</connectionStrings>
17
<system.web>
18
<!--
19
设置 compilation debug="true" 将调试符号插入
20
已编译的页面中。但由于这会
21
影响性能,因此只在开发过程中将此值
22
设置为 true。
23
-->
24
<compilation debug="true"/>
25
<!--
26
通过 <authentication> 节可以配置 ASP.NET 使用的
27
安全身份验证模式,
28
以标识传入的用户。
29
-->
30
<authentication mode="Windows"/>
31
<!--
32
如果在执行请求的过程中出现未处理的错误,
33
则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
34
开发人员通过该节可以配置
35
要显示的 html 错误页
36
以代替错误堆栈跟踪。
37
38
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
39
<error statusCode="403" redirect="NoAccess.htm" />
40
<error statusCode="404" redirect="FileNotFound.htm" />
41
</customErrors>
42
-->
43
</system.web>
44
</configuration>

2

3

4

5

6

7

8

9

10

11

12

13

14

Persist Security Info=True;Jet OLEDB:Database Password=123"
15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

相关连接:运行时修改数据库连接字符串(ConnectionString),VS2005运行时修改配置文件(.config)
本文地址:http://www.cnblogs.com/anjou/archive/2006/08/27/487860.html