TableNotEnabledForNotificationException Class
The exception that is thrown when a SqlCacheDependency class is used against a database table that is not enabled for change notifications.
System.Exception
System.SystemException
System.Web.Caching.TableNotEnabledForNotificationException
Namespace: System.Web.Caching
Assembly: System.Web (in System.Web.dll)
The TableNotEnabledForNotificationException type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | TableNotEnabledForNotificationException() | Initializes a new instance of the TableNotEnabledForNotificationException class. |
![]() | TableNotEnabledForNotificationException(String) | Initializes a new instance of the TableNotEnabledForNotificationException class with the specified error message. |
![]() | TableNotEnabledForNotificationException(String, Exception) | Initializes a new instance of the TableNotEnabledForNotificationException class with a specified error message and a reference to the inner exception that is the cause of this exception. |
| Name | Description | |
|---|---|---|
![]() | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from Exception.) |
![]() | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from Exception.) |
![]() | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from Exception.) |
![]() | InnerException | Gets the Exception instance that caused the current exception. (Inherited from Exception.) |
![]() | Message | Gets a message that describes the current exception. (Inherited from Exception.) |
![]() | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from Exception.) |
![]() | StackTrace | Gets a string representation of the immediate frames on the call stack. (Inherited from Exception.) |
![]() | TargetSite | Gets the method that throws the current exception. (Inherited from Exception.) |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | GetBaseException | When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions. (Inherited from Exception.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetObjectData | When overridden in a derived class, sets the SerializationInfo with information about the exception. (Inherited from Exception.) |
![]() | GetType | Gets the runtime type of the current instance. (Inherited from Exception.) |
![]() | ToString | Creates and returns a string representation of the current exception. (Inherited from Exception.) |
The following code example attempts to create a SqlCacheDependency object and add an item to the Cache with a dependency on the SqlCacheDependency object. If the SQL Server database table is not enabled for dependency notifications, the TableNotEnabledForNotificationException is thrown and handled by calling the SqlCacheDependencyAdmin.EnableTableForNotifications method.
public void Page_Load(object Src, EventArgs E) { // Declare the SqlCacheDependency instance, SqlDep. SqlCacheDependency SqlDep = null; // Check the Cache for the SqlSource key. // If it isn't there, create it with a dependency // on a SQL Server table using the SqlCacheDependency class. if (Cache["SqlSource"] == null) { // Because of possible exceptions thrown when this // code runs, use Try...Catch...Finally syntax. try { // Instantiate SqlDep using the SqlCacheDependency constructor. SqlDep = new SqlCacheDependency("Northwind", "Categories"); } // Handle the DatabaseNotEnabledForNotificationException with // a call to the SqlCacheDependencyAdmin.EnableNotifications method. catch (DatabaseNotEnabledForNotificationException exDBDis) { try { SqlCacheDependencyAdmin.EnableNotifications("Northwind"); } // If the database does not have permissions set for creating tables, // the UnauthorizedAccessException is thrown. Handle it by redirecting // to an error page. catch (UnauthorizedAccessException exPerm) { Response.Redirect(".\\ErrorPage.htm"); } } // Handle the TableNotEnabledForNotificationException with // a call to the SqlCacheDependencyAdmin.EnableTableForNotifications method. catch (TableNotEnabledForNotificationException exTabDis) { try { SqlCacheDependencyAdmin.EnableTableForNotifications("Northwind", "Categories"); } // If a SqlException is thrown, redirect to an error page. catch (SqlException exc) { Response.Redirect(".\\ErrorPage.htm"); } } // If all the other code is successful, add MySource to the Cache // with a dependency on SqlDep. If the Categories table changes, // MySource will be removed from the Cache. Then generate a message // that the data is newly created and added to the cache. finally { Cache.Insert("SqlSource", Source1, SqlDep); CacheMsg.Text = "The data object was created explicitly."; } } else { CacheMsg.Text = "The data was retrieved from the Cache."; } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
