zoukankan      html  css  js  c++  java
  • asp.net2.0 缓存:数据库依赖

    Web.config

    <configuration>

     <appSettings/>

     <connectionStrings>
      <add name="TestConnectionString" connectionString="server=shgpc150\sql2k;database=Northwind;uid=sa;pwd=;"></add>
     </connectionStrings>

     <system.web>
      <caching>
       <sqlCacheDependency enabled="true" pollTime="1000">
        <databases>
         <add name="Northwind" connectionStringName="TestConnectionString" pollTime="1000"></add>
        </databases>
       </sqlCacheDependency>
      </caching>
    ............


    Page_Load.

    System.Web.Caching.SqlCacheDependencyAdmin.EnableNotifications(System.Configuration.ConfigurationManager.ConnectionStrings["TestConnectionString"].ConnectionString);
            System.Web.Caching.SqlCacheDependencyAdmin.EnableTableForNotifications(System.Configuration.ConfigurationManager.ConnectionStrings["TestConnectionString"].ConnectionString, "Employees");

            if (HttpContext.Current.Cache["dsEmpployees"] == null)
            {
                System.Web.Caching.SqlCacheDependency depe = new System.Web.Caching.SqlCacheDependency("Northwind", "Employees");
                HttpContext.Current.Cache.Insert("dsEmpployees", "dsEmpployees", depe);
                Label1.Text = "new cache generated!";
            }
            else
            {
                Label1.Text = "Load data from cache";
            }

  • 相关阅读:
    word 改造成html表单
    ceshi
    easyUI 多功能datagrid 用户控件
    easyUI 多功能datagrid
    实现easyUI+.net 商品管理的用户控件
    通过sql 实现简单分页(not in)
    Jquery 插件开发
    Hello Swift
    关于const_cast转换
    undefined reference to '__android_log_print'.
  • 原文地址:https://www.cnblogs.com/silva/p/692835.html
Copyright © 2011-2022 走看看