在web.config中数据库链接
<connectionStrings>
<add name="ConnectionString" connectionString="server=.;uid=sa;pwd=123;database=OurWeb"/>
</connectionStrings>
1.添加System.Configuration.dll
2.引用using System.Configuration
3.获取链接
string conSQL = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;