📄 default.aspx
字号:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e)
{
DataSet myCustomers;
myCustomers = (DataSet)Cache["firmCustomers"];
if (myCustomers == null)
{
SqlConnection conn = new SqlConnection( ConfigurationManager.ConnectionStrings["AppConnectionString1"].ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("Select * from Customers", conn);
myCustomers = new DataSet();
da.Fill(myCustomers);
SqlCacheDependency myDependency = new SqlCacheDependency("Northwind", "Customers");
Cache.Insert("firmCustomers", myCustomers, myDependency);
Label1.Text = "Produced from database.";
}
else
{
Label1.Text = "Produced from Cache object.";
}
GridView1.DataSource = myCustomers;
GridView1.DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Sql Cache Invalidation</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" Runat="server"></asp:Label><br />
<br />
<asp:GridView ID="GridView1" Runat="server"></asp:GridView>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -