Blog SeriesArticle: Learn about the SQL cache of the data source control in the cache & sqlcachedependency section of ASP. NET 2.0 (C #) (4:
Set the following attributes for the datasource control: enablecaching = "true" sqlcachedependency = "cachetest: cachetest" cacheduration = "infinite"
For sqlserver2005, change it to sqldependency = "commandnotification"
Note the configuration in the configuration file
I tested it and summarized two points:
1. As long as the data source control adopts the following Configuration:
Code
< ASP: objectdatasource ID = " Objectperformance1 " Runat = " Server "
Selectmethod = " Getcachetests "
Typename = " Sqlcache. BLL. cachetest "
Enablecaching = " True "
Cacheduration = " 10 "
Sqlcachedependency = " Commandnotification " >
</ ASP: objectdatasource >
No additional things are required for both SQL2000, 2005, and 2008, and the configuration file does not need to write anything.
2. If the data source control is configured as follows:
Code
< ASP: objectdatasource ID = " Objectperformance1 " Runat = " Server "
Selectmethod = " Getcachetests "
Typename = " Sqlcache. BLL. cachetest "
Enablecaching = " True "
Cacheduration = " 10 "
Sqlcachedependency = " Cachetest: cachetest " >
</ ASP: objectdatasource >
Or
< ASP: objectdatasource ID = " Objectperformance1 " Runat = " Server "
Selectmethod = " Getcachetests "
Typename = " Sqlcache. BLL. cachetest "
Enablecaching = " True "
Cacheduration = " Infinite "
Sqlcachedependency = " Cachetest: cachetest " >
</ ASP: objectdatasource >
Whether it is SQL2000, 2005, or 2008, the configuration file must be written as follows:
Code
< Caching >
< Sqlcachedependency Enabled = " True " Polltime = " 10000 " >
< Databases >
< Add name = " Cachetest " Connectionstringname = " Mssqlconnstring " />
</ Databases >
</ Sqlcachedependency >
// If it is sqlserver2005, you only need to set it as follows, because sqlserver supports notification-based cache failure.
// <Sqlcachedependency enabled = "true"/>
// If the number is 7th rows, it is incorrect.
</ Caching >
You must also use the aspnet_regsql.exe tool to notify the database.
My testsCode: Sqlcache.rar