不配置web.config的时候,写在程序中。
SqlConnection mySqlConnection = new SqlConnection(“server=(local); database=northwind; UserId=sa;Pwd= ");
配置web.config
<appSettings>
<add key="conn" value="server=(local);user id=sa;database=BookSystem;pwd="></add>
</appSettings>
在程序中调用web.config中的数据库连接字符串
SqlConnection conn=new SqlConnection(System.Configuration .ConfigurationSettings .AppSettings ["conn"]);