在web.config 中输入 ConnectionString 避免每次连接数据库都要写 ConnectionString

web.config

<configuration>

<appSettings>
  <add key="DBConnectionString" value="server=localhost;database=web;uid=sa; pwd="/>
 </appSettings>
</configuration>

----------------------------------------------------------------------------------------------------------

xxx.aspx.cs

SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["DBConnectionString"]);

posted @   邓维  阅读(268)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示