asp.net获取数据库连接字符串

1、添加引用

using System.Configuration;

2、代码

string strConnectionString=ConfigurationManager.AppSettings["LocalConnectionString"].ToString();

3、web.config

<configuration>
  <appSettings>
    <add key="LocalConnectionString" value="User id=sa;Password=123456;Database=Users;Server=192.168.1.1;Connect Timeout=50;Max Pool size=200;Min pool Size=5"/>
  </appSettings>
</configuration>

  

posted @ 2016-11-21 14:21  冷战  阅读(1502)  评论(0编辑  收藏  举报