Steps for using the SQL data cache dependency Function

Source: Internet
Author: User
Tags connectionstrings
To use the SQL data cache dependency function, perform the following three steps:
1. Configure the SQL Server database to enable the SQL database cache dependency support
How to implement this step: 1: You can use the "Visual Studio 2005 command prompt": if you do not understand the configuration, you can use apsnet_regsql.exe -? Command to view help documentation
// Enable the database dependency Function
Aspnet_regsql.exe-s localhost-U sa-P Sa-D database name-ed
// Enable the dependency function of the database table
Aspnet_regsql.exe-s localhost-U sa-P Sa-D database name-T table name-et
// Disable the data cache dependency function of the database
Aspnet_regsql.exe-s localhost-U sa-P Sa-D database name-dd
// Disable the data cache dependency function of a data table
Aspnet_regsql.exe-s localhost-U sa-P Sa-D database name-T table name-dt
2: Use the sqlcachedependencyadmin class to implement the same configuration function

Ii. Configure the Web. config file
<Configuration>
<Appsettings/>
<Connectionstrings>
<Add Name = "pubsconnectionstring "Connectionstring =" Data Source = wangxiaojun; initial catalog = pubs; Integrated Security = true"
Providername = "system. Data. sqlclient"/>
</Connectionstrings>
<System. Web>
<Caching>
<Sqlcachedependency enabled = "true" polltime = "600">
<Databases>
<Add name = "pubs" connectionstringname = "pubsconnectionstring"/>
</Databases>
</Sqlcachedependency>
</Caching>
</System. Web>
</Configuration>

Iii. Implementation of specific applications Program , Using the SQL data cache dependency Function
Use
<% @ Outputcache duration = "1000" sqldependency = "pubs: Jobs" varybyparam = "NONE" %>

Or use
<Asp: sqldatasource id = "sqldatasource1" runat = "server" Enablecaching = "true" sqlcachedependency = "pubs: jobs "
Connectionstring = "<% $ connectionstrings: pubsconnectionstring %>"
Selectcommand = "select [job_id], [job_desc], [min_lvl], [max_lvl] from [jobs]">
</ASP: sqldatasource>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.