怎样把数据库的连接字符串写在wed站点的Config(配置文件)中

 

只需在web.config文件中写下如下字段

<configuration>

<appSettings>

<add key="索引值" value="数据库连接字符串"/>

</appSettings>

</configuration>

在页面只中调用

如果没有ConfigurationManager类  应引入using System.Configuration;

命名空间

  string connStr = ConfigurationManager.AppSettings["索引值"].ToString();

 

 

 

posted @ 2012-05-20 12:08  独剑  阅读(152)  评论(0编辑  收藏  举报