System.Configuration.ConfigurationManager.AppSettings["connString"];

在.net1.1 string strConnection = System.Configuration.ConfigurationSettings.AppSettings["connString"]; 在.net2.0 VS2005提示 警告: “System.Configuration.ConfigurationSettings.AppSettings”已过时:“This method is obsolete, it has been replaced by System.Configuration!

 解决方法 string strConnection = System.Configuration.ConfigurationManager.AppSettings["connString"];

对应的web.config设置为:

<appSettings>
    <add key ="connString" value ="server=(local);uid=sa;pwd=sa;database=testDataBase;"/>
  </appSettings>

另一种方法是:

        ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings["hello"];
        string cn = cs.ConnectionString;

对应的web.config设置为:

 <connectionStrings>
  <add name ="hello" connectionString ="server=(local);uid=sa;pwd=sa;database=testDataBase" providerName ="System.Data.SqlClient"/> 
</connectionStrings>

阅读更多
文章标签: string server .net
个人分类: c#开发
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

System.Configuration.ConfigurationManager.AppSettings["connString"];

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭