1、在Web.config中配置
2、创建方法public static SqlConnection GetConnection()
{
string connectionString = ConfigurationManager.ConnectionStrings["数据库名称"].ConnectionString;
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
return connection;
}
3、通过SqlCommand执行