在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 @ 2009-07-02 09:33  邓维  阅读(268)  评论(0编辑  收藏  举报