System.Web 2.0.0.0 System.Web.Caching.CacheDependency

On all supported versions of SQL Server (Microsoft SQL Server 7.0, Microsoft SQL Server 2000, and SQL Server 2005) the class monitors a specific SQL Server database table. When the table changes, items associated with the table are removed from the , and a new version of the item is added to the .

The class also supports integration with the class when using a sqprsqlong database. The query notification mechanism of sqprsqlong detects changes to data that invalidate the results of an SQL query and removes any cached items associated with the SQL query from the .

You can use the class to add items to your application's that are dependent on either a SQL Server database table or on an SQL query when using sqprsqlong. You can also use this class with the @ OutputCache directive to make an output-cached page or a user control dependent on a SQL Server database table. Finally, you can use the class with the @ OutputCache page directive to make an output-cached page dependent on the results of an SQL query when using sqprsqlong. Query notification using sqprsqlong is not supported on the @ OutputCache directive for user controls.

For this class to work correctly when using table-based notifications, the database and any tables that you want to make dependencies on must have notifications enabled. You can enable notifications by calling methods of the class or by using the Aspnet_regsql.exe command-line tool. In addition, the proper configuration settings must be included in the application's Web.config file.

Using a object with sqprsqlong query notification does not require any explicit configuration. Consult the sqprsqlong Books Online for information about restrictions on the types of Transact-SQL queries that are allowed when using query notification.

The following example shows an ASP.NET Web.config file that enables table-based dependencies on a SQL Server database table.

`<configuration> <connectionStrings> <add name="Northwind" connectionString="Data Source=(local); Initial Catalog=northwind; Integrated Security=true"; providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <caching> <sqlCacheDependency enabled = "true" pollTime = "60000" > <databases> <add name="northwind" connectionStringName="Northwind" pollTime="9000000" /> </databases> </sqlCacheDependency> </caching> </system.web> </configuration>`

Establishes a relationship between an item stored in an ASP.NET application's object and either a specific SQL Server database table or the results of a sqprsqlong query. This class cannot be inherited.

- Constructor
  2.0.0.0

  This constructor is used to create objects that use the query-notification feature of sqprsqlong products.

  SQL statements that are associated with the parameter must include the following:

  Fully qualified table names, including the name of the table owner. For example, to refer to a table named Customers that is owned by the database owner, the SQL statement must refer to dbo.customers.

  Explicit column names in the Select statement. You cannot use the asterisk (*) wildcard character to select all columns from a table. For example, instead of select * from dbo.customers, you must use select name, address, city, state from dbo.customers.

  This constructor cannot be used to associate a instance with a instance on a page using sqprsqlong query notifications with page-level output caching.

  Initializes a new instance of the class, using the supplied to create a cache-key dependency.

  A that is used to create a object.
- Constructor
  2.0.0.0

  This constructor is used to create objects for SQL Server 7.0 and SQL Server 2000 products.

  The database name passed to the parameter must be defined in the application's Web.config file. For example, the following Web.config file defines a database named pubs for change notifications.

  <configuration> <connectionStrings> <add name="Pubs" connectionString="Data Source=(local); Initial Catalog=pubs; Integrated Security=true"; providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <caching> <sqlCacheDependency enabled = "true" pollTime = "60000" > <databases> <add name="pubs" connectionStringName="pubs" pollTime="9000000" /> </databases> </sqlCacheDependency> </caching> </system.web> </configuration>

  Two exceptions are commonly thrown when this constructor is used: and . If a is thrown, you can call the method in exception-handling code, or use the Aspnet_regsql.exe command-line tool to set up the database for notifications. If a is thrown, you can call the method or use Aspnet_regsql.exe to set up the table for notifications.

  Initializes a new instance of the class, using the supplied parameters to create a cache-key dependency.

  The name of a database defined in the databases element of the application's Web.config file.
  The name of the database table that the is associated with.
- Method
  2.0.0.0
  System.String

  The method returns an identifier used to uniquely track objects associated with an item or application. The unique identifier generated when using table-based notifications is partially dependent on the change identifier generated by the database.

  When using SQL Server 2005-based query notifications, the unique identifier is null because sqprsqlong does not support returning unique identifiers for individual query notifications.

  Retrieves a unique identifier for a object.

  The unique identifier for the object, or null if no identifier can be generated.