SQL Cache Dependency
Category:
C#, VB.NET, ASP.NETType:
ClassesDifficulty:
AdvancedAuthor:
AnonymousVersion Compatibility: Visual Basic.NET
More information:
Add the following to the web.config file in the section
' NB. DatabaseD is a label of your choice. Adjust the connectionstringname to use your connectionstring
' DatabaseD in the web.config and the namespace of the database layer must match.
'
' polltime is the milliseconds the asp.net web server polls the database for cache expiration
'
'
'
'
'
'
'
'
'
' Set the SQL database to perform CacheDependency
'
' run the following command from a command window
' C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe -S "servername" -E -d databasename -ed
'
' this creates the aspnet_sql table
'
' run the following command from a command window for each database table
' C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe -S "servername" -E -d databasename -t tablename -et
' this creates the entry in the aspnet_sql table and a trigger for insert,update,delete functions
'
' create a dataset in app_code for the table/query thats required
'
' for the database layer, follow the instructions below (also see the code)
'
' SQL Cached Dependency for dsGenericDS, with time based cache contingency for multiple table queries
'
' Name the DatabaseLayer Class as GenericDS_DatabaseLayer
' eg Project_DatabaseLayer
'
' Replace all references of GenericDS with the suffix of the dataset, eg Project for dsProject
' Replace all references of GenericTA with the TableAdapter name, eg, Project
Instructions: Copy the declarations and code below and paste directly into your VB project.
Declarations: