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>