SqlCacheDependencyAdmin.EnableTableForNotifications Method (String, String[])

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Connects to the specified SQL Server database and enables the specified array of database tables for SqlCacheDependency change notification.

Namespace:   System.Web.Caching
Assembly:  System.Web (in System.Web.dll)

public static void EnableTableForNotifications(
	string connectionString,
	string[] tables
)

Parameters

connectionString
Type: System.String

A connection string used to connect to the SQL Server database.

tables
Type: System.String[]

The array of SQL Server database tables on which to enable change notifications.

Exception Condition
DatabaseNotEnabledForNotificationException

The database is not enabled for change notifications.

ArgumentException

One of the values in the tables parameter is null.

-or-

One of the values in the tables parameter is an empty string ("").

ArgumentNullException

tables is null.

HttpException

A connection to the database could not be established.

-or-

The security context of the ASP.NET application does not have permission to connect to the database.

-or-

The security context of the ASP.NET application does not have permission to disable notifications for the database.

The EnableTableForNotifications method adds change notifications for the tables specified in the tables parameter. These tables must be in the database specified in the connectionString parameter.

Once you have used the EnableTableForNotifications method to add change notifications to a group of tables, you must use one of the DisableTableForNotifications overloads if you wish to disable change notifications.

The following code example uses the EnableTableForNotifications method to enable change notifications on the tables specified in a semicolon-delimited list in the database specified in the connection string MyConnectionString.

For the full code required to run the example, see the Example section of the SqlCacheDependencyAdmin class overview topic.

SqlCacheDependencyAdmin.EnableTableForNotifications(
  ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString,
  tableName.Text);

.NET Framework
Available since 2.0
Return to top
Show: