注册 登录
编程论坛 ASP.NET技术论坛

.net 1.1 web.config配置问题

wxm198427 发布于 2009-10-27 09:30, 1030 次点击
我写了一段这样的代码,<configuration>
<appSettings>
<add key="conn" value="Data Source=localhost;Initial Catalog=mysite;User ID=;Password=" providerName="System.Data.SqlClient"/>
</appSettings>
………………
调试说没有相关的源行,请问这个是什么原因,请各位高手赐教,本人。NET菜鸟一个,谢谢谢谢…………
4 回复
#2
bygg2009-10-27 09:59
providerName="System.Data.SqlClient" 这个去年试试
#3
wxm1984272009-10-27 10:29
回复 2楼 bygg
不行,去掉后又出现这样的一句:

 Invalid section name. The section 'dataConfiguration' does not exist in the requested configuration file 'D:/Project/mysite/web.config' or the file 'c:\windows\\framework\v1.1.4322\Config\machine.config'. Make sure that the 'enterpriseLibrary.configurationSections' configuration section exists in one of the files and that the section 'dataConfiguration' is defined.
源错误:


[没有相关的源行]
 

源文件: 无    行: 0
 
这个又是什么原因,这个'dataConfiguration' 在哪,怎么写?谢谢
#4
bygg2009-10-27 14:47
'dataConfiguration' 你这个东西是什么啊?
#5
wxm1984272009-10-28 09:46
回复 4楼 bygg
哦,首先我引用了Microsoft.Practices.EnterpriseLibrary.Configuration这个,就是想让这个去读取数据库信息,但是在 web.config中我要怎么写这个呢?第二,其实我觉得我用Microsoft.Practices.EnterpriseLibrary.Configuration跟<appsettings><add name="conn" server=""……></appsettings>  string conn= System.Configuration.ConfigurationSettings.AppSettings["conn"];SqlConnection sc = new SqlConnection("conn");sc.open();的用法是完成同样的效果就是连接数据库,打开连接你说是不是?但是我不知道引用一个Microsoft.Practices.EnterpriseLibrary.Configuration这样的该如何在web.config中写就是?所以我觉得就是因为我用的2个方法冲突了,选其中之一就行,你说是不是?  帮忙研究一下Microsoft.Practices.EnterpriseLibrary.Configuration,
1