TableNotEnabledForNotificationException Třída

Definice

Výjimka, která se vyvolá při SqlCacheDependency použití třídy v databázové tabulce, která není povolena pro oznámení o změnách.

public ref class TableNotEnabledForNotificationException sealed : SystemException
[System.Serializable]
public sealed class TableNotEnabledForNotificationException : SystemException
[<System.Serializable>]
type TableNotEnabledForNotificationException = class
    inherit SystemException
Public NotInheritable Class TableNotEnabledForNotificationException
Inherits SystemException
Dědičnost
TableNotEnabledForNotificationException
Atributy

Příklady

Následující příklad kódu se pokusí vytvořit SqlCacheDependency objekt a přidat položku do Cache objektu se závislostí na objektu SqlCacheDependency . Pokud SQL Server tabulka databáze není povolena pro oznámení závislostí, vyvolá TableNotEnabledForNotificationException se a zpracuje voláním SqlCacheDependencyAdmin.EnableTableForNotifications metody.

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

Konstruktory

TableNotEnabledForNotificationException()

Inicializuje novou instanci TableNotEnabledForNotificationException třídy.

TableNotEnabledForNotificationException(String)

Inicializuje novou instanci třídy se zadanou chybovou TableNotEnabledForNotificationException zprávou.

TableNotEnabledForNotificationException(String, Exception)

Inicializuje novou instanci TableNotEnabledForNotificationException třídy se zadanou chybovou zprávou a odkazem na vnitřní výjimku, která je příčinou této výjimky.

Vlastnosti

Data

Získá kolekci párů klíč/hodnota, které poskytují další uživatelem definované informace o výjimce.

(Zděděno od Exception)
HelpLink

Získá nebo nastaví odkaz na soubor nápovědy přidružený k této výjimce.

(Zděděno od Exception)
HResult

Získá nebo nastaví HRESULT, kódovanou číselnou hodnotu přiřazenou konkrétní výjimce.

(Zděděno od Exception)
InnerException

Exception Získá instanci, která způsobila aktuální výjimku.

(Zděděno od Exception)
Message

Získá zprávu, která popisuje aktuální výjimku.

(Zděděno od Exception)
Source

Získá nebo nastaví název aplikace nebo objektu, který způsobuje chybu.

(Zděděno od Exception)
StackTrace

Získá řetězcové znázornění okamžitých rámců v zásobníku volání.

(Zděděno od Exception)
TargetSite

Získá metodu, která vyvolá aktuální výjimku.

(Zděděno od Exception)

Metody

Equals(Object)

Určí, zda se zadaný objekt rovná aktuálnímu objektu.

(Zděděno od Object)
GetBaseException()

Při přepsání v odvozené třídě vrátí Exception hodnotu, která je hlavní příčinou jedné nebo více následných výjimek.

(Zděděno od Exception)
GetHashCode()

Slouží jako výchozí funkce hash.

(Zděděno od Object)
GetObjectData(SerializationInfo, StreamingContext)

Při přepsání v odvozené třídě nastaví s SerializationInfo informacemi o výjimce.

(Zděděno od Exception)
GetType()

Získá typ modulu runtime aktuální instance.

(Zděděno od Exception)
MemberwiseClone()

Vytvoří použádnou kopii aktuálního souboru Object.

(Zděděno od Object)
ToString()

Vytvoří a vrátí řetězcovou reprezentaci aktuální výjimky.

(Zděděno od Exception)

událost

SerializeObjectState
Zastaralé.

Nastane, když je výjimka serializována k vytvoření objektu stavu výjimky, který obsahuje serializovaná data o výjimce.

(Zděděno od Exception)

Platí pro