C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/aspnet_regsql.exe -S 服务器 -U 用户名 -P 密码 -ed -d 数据库名 -et -t 表名
以上命令启用SQL轮询数据依赖缓存
web.config的<system.web>节中添加以下配置
<!--SQL轮询数据绶存-->
<caching>
<sqlCacheDependency enabled="true" pollTime="2000">
<databases>
<add name="webs" connectionStringName="websConnectionString" />
</databases>
</sqlCacheDependency>
</caching>
(1)页面输出缓存中使用SQL轮询依赖缓存
<% OutputCache Duration="时间" SqlDependency="启用的数据库:表名" varyByParam="none">
(2)数据源中使用SQL轮询缓存
<asp:SqlDataSource ID="sqlDataSource2" EnableCaching="true" SqlCacheDependency="启用的数据库名:表名" SelectCommand="select id,name......" ConnectionString="<%$ConnectionString:mySqlServer%>" Runat="Server" />
(3)应用程序数据缓存
SqlCacheDependency scd=new SqlCacheDependency("webs","wareInfo");
Cache.Insert("TitleCount",count,scd);