TableNotEnabledForNotificationException TableNotEnabledForNotificationException TableNotEnabledForNotificationException TableNotEnabledForNotificationException Class

Definizione

L'eccezione generata quando viene utilizzata una classe SqlCacheDependency viene utilizzata con una tabella di database non attivata per le notifiche delle modifiche.The exception that is thrown when a SqlCacheDependency class is used against a database table that is not enabled for change notifications.

public ref class TableNotEnabledForNotificationException sealed : SystemException
[System.Serializable]
public sealed class TableNotEnabledForNotificationException : SystemException
type TableNotEnabledForNotificationException = class
    inherit SystemException
Public NotInheritable Class TableNotEnabledForNotificationException
Inherits SystemException
Ereditarietà
TableNotEnabledForNotificationExceptionTableNotEnabledForNotificationExceptionTableNotEnabledForNotificationExceptionTableNotEnabledForNotificationException
Attributi

Esempi

Il codice seguente tenta di creare un SqlCacheDependency dell'oggetto e aggiungere un elemento per il Cache con una dipendenza di SqlCacheDependency oggetto.The following code example attempts to create a SqlCacheDependency object and add an item to the Cache with a dependency on the SqlCacheDependency object. Se la tabella di database di SQL Server non è abilitata per le notifiche di dipendenza, il TableNotEnabledForNotificationException generata e gestita chiamando il SqlCacheDependencyAdmin.EnableTableForNotifications (metodo).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."; 
    } 
} 
Sub Page_Load(Src As Object, E As EventArgs)
   ' Declare the SqlCacheDependency instance, SqlDep.
   Dim SqlDep As SqlCacheDependency

   ' 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") Is Nothing

      ' 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 exDBDis As DatabaseNotEnabledForNotificationException
         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 exPerm As UnauthorizedAccessException
             Response.Redirect(".\ErrorPage.htm")
         End Try

      ' Handle the TableNotEnabledForNotificationException with
            ' a call to the SqlCacheDependencyAdmin.EnableTableForNotifications method.
      Catch exTabDis As TableNotEnabledForNotificationException
         Try
            SqlCacheDependencyAdmin.EnableTableForNotifications( _
             "Northwind", "Categories")

         ' If a SqlException is thrown, redirect to an error page.
         Catch exc As SqlException
             Response.Redirect(".\ErrorPage.htm")
         End Try

      ' 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."

      End Try

    Else
       CacheMsg.Text = "The data was retrieved from the Cache."
    End If
End Sub

Costruttori

TableNotEnabledForNotificationException() TableNotEnabledForNotificationException() TableNotEnabledForNotificationException() TableNotEnabledForNotificationException()

Inizializza una nuova istanza della classe TableNotEnabledForNotificationException.Initializes a new instance of the TableNotEnabledForNotificationException class.

TableNotEnabledForNotificationException(String) TableNotEnabledForNotificationException(String) TableNotEnabledForNotificationException(String) TableNotEnabledForNotificationException(String)

Inizializza una nuova istanza della classe TableNotEnabledForNotificationException con il messaggio di errore specificato.Initializes a new instance of the TableNotEnabledForNotificationException class with the specified error message.

TableNotEnabledForNotificationException(String, Exception) TableNotEnabledForNotificationException(String, Exception) TableNotEnabledForNotificationException(String, Exception) TableNotEnabledForNotificationException(String, Exception)

Inizializza una nuova istanza della classe TableNotEnabledForNotificationException con un messaggio di errore specificato e un riferimento all'eccezione interna che è la causa dell'eccezione corrente.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.

Proprietà

Data Data Data Data

Ottiene una raccolta di coppie chiave-valore che fornisce informazioni aggiuntive definite dall'utente relative all'eccezione.Gets a collection of key/value pairs that provide additional user-defined information about the exception.

(Inherited from Exception)
HelpLink HelpLink HelpLink HelpLink

Ottiene o imposta un collegamento al file della Guida associato all'eccezione.Gets or sets a link to the help file associated with this exception.

(Inherited from Exception)
HResult HResult HResult HResult

Ottiene o imposta HRESULT, un valore numerico codificato che viene assegnato a un'eccezione specifica.Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

(Inherited from Exception)
InnerException InnerException InnerException InnerException

Ottiene l'istanza di Exception che ha causato l'eccezione corrente.Gets the Exception instance that caused the current exception.

(Inherited from Exception)
Message Message Message Message

Ottiene un messaggio che descrive l'eccezione corrente.Gets a message that describes the current exception.

(Inherited from Exception)
Source Source Source Source

Ottiene o imposta il nome dell'oggetto o dell'applicazione che ha generato l'errore.Gets or sets the name of the application or the object that causes the error.

(Inherited from Exception)
StackTrace StackTrace StackTrace StackTrace

Ottiene una rappresentazione di stringa dei frame immediati nello stack di chiamate.Gets a string representation of the immediate frames on the call stack.

(Inherited from Exception)
TargetSite TargetSite TargetSite TargetSite

Ottiene il metodo che genera l'eccezione corrente.Gets the method that throws the current exception.

(Inherited from Exception)

Metodi

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetBaseException() GetBaseException() GetBaseException() GetBaseException()

Se utilizzato come metodo di override in una classe derivata, restituisce l'Exception che è la causa radice di una o più eccezioni successive.When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.

(Inherited from Exception)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Funge da funzione hash predefinita.Serves as the default hash function.

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

Quando l'override viene eseguito in una classe derivata, imposta il controllo SerializationInfo per la colonna.When overridden in a derived class, sets the SerializationInfo with information about the exception.

(Inherited from Exception)
GetType() GetType() GetType() GetType()

Ottiene il tipo di runtime dell'istanza corrente.Gets the runtime type of the current instance.

(Inherited from Exception)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Crea e restituisce una rappresentazione di stringa dell'eccezione corrente.Creates and returns a string representation of the current exception.

(Inherited from Exception)

Eventi

SerializeObjectState SerializeObjectState SerializeObjectState SerializeObjectState

Si verifica quando un'eccezione viene serializzata per creare un oggetto di stato eccezione contenente i dati serializzati relativi all'eccezione.Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception.

(Inherited from Exception)

Si applica a