在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"]);