if (Cache["test"] == null) { string connectionString = ConfigurationManager.ConnectionStrings["book"].ConnectionString; SqlConnection myConnection = new SqlConnection(connectionString); SqlDataAdapter ad = new SqlDataAdapter("SELECT * from test", myConnection); DataSet ds = new DataSet(); ad.Fill(ds); SqlCacheDependency sqlDepend = new SqlCacheDependency(ad.SelectCommand); Cache.Insert("test", ds, sqlDepend); } GridView2.DataSource = Cache["test"] as DataSet; GridView2.DataBind();
<caching> <sqlCacheDependency enabled="true"> <databases> <add connectionStringName="book" name="book"/> </databases> </sqlCacheDependency> </caching>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)