请问webconfig连接数据库
比如我在webconfig里配置
<appSettings >
<add key="DSN" value="server=ADMIN;uid=sa;pwd=35144315;database=ms"/ >
<add key="bgColor" value="blue"/ >
</appSettings >
调用
string conn2 = System.Configuration.ConfigurationSettings.AppSettings["DSN"];
警告 1 “System.Configuration.ConfigurationSettings.AppSettings”已过时:“This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings” C:\Documents and Settings\Administrator\桌面1\Default.aspx.cs 20 28 C:\...\桌面1\
请问怎么实现和
SqlConnection conn=new SqlConnection("server=ADMIN;uid=sa;pwd=35144315;database=ms");
conn.open;
一样的效果? 谢谢
------解决方案--------------------这样引用就不过时了
System.Configuration.ConfigurationManager.AppSettings["DSN"];