asp.net 2.0 读取web.config问题
今天把一个项目从1.1转成了2.0,发现系统有一个警告:
警告 1 “Public Shared ReadOnly Property AppSettings() As System.Collections.Specialized.NameValueCollection”已过时:“This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings
我的语句无非就是从web.config中读取数据库连接字符串(Private Shared ReadOnly path As String = System.Configuration.ConfigurationSettings.AppSettings( "DAL ")),在1.1运行都正常的,2.0是不是有什么改变?
------解决方案--------------------那就换成System.Configuration.ConfigurationManager.AppSettings吧
------解决方案--------------------是的 2.0用 System.Configuration.ConfigurationManager.AppSettings
------解决方案--------------------ConfigurationManager.ConnectionStrings[ "SQLConnString2 "].ConnectionString;
using System.Configuration;
------解决方案-------------------- <connectionStrings>
<add name= "SqlConnect1 " connectionString= "server:local;uid=sa;pwd=;database=pubs " />
</connectionStrings>
------解决方案--------------------把上面的sqlConnect1改成SQLConnString2就可以用了
------解决方案--------------------项目右键引用 System.Configuration