1.使用aspnet_regsql启动数据库依赖项
aspnet_regsql -S localhost\sqlexpress -E -d MyBookShop -ed -t users -et
2.配置Web.Config使用数据库依赖项
1)配置连接字符串
<connectionStrings>
<add name="db" connectionString="server=.\sqlexpress;uid=sa;pwd=xfaccp;database=MyBookShop;"/>
</connectionStrings>
2)配置Sql缓存依赖项
<caching>
<sqlCacheDependency enabled="true">
<databases>
<add name="MyBookShop" connectionStringName="db" pollTime="1000"/>
</databases>
</sqlCacheDependency>
</caching>
3.代码中设置使用依赖项
Cache.Insert("ds", ds,new System.Web.Caching.SqlCacheDependency("MyBookShop","users"), DateTime.Now.AddSeconds(120), TimeSpan.Zero);
配置数据库依赖项
最新推荐文章于 2023-04-09 15:25:56 发布