SqlCacheDependencyAdmin.EnableTableForNotifications 方法

定義

連接到 SQL Server 資料庫,並準備要管理 SqlCacheDependency 變更告知的一或多個資料庫資料表。

多載

EnableTableForNotifications(String, String)

連接到指定的 SQL Server 資料庫,並啟用指定資料庫資料表的 SqlCacheDependency 變更告知。

EnableTableForNotifications(String, String[])

連接到指定的 SQL Server 資料庫,並啟用指定資料庫資料表陣列的 SqlCacheDependency 變更告知。

EnableTableForNotifications(String, String)

連接到指定的 SQL Server 資料庫,並啟用指定資料庫資料表的 SqlCacheDependency 變更告知。

public:
 static void EnableTableForNotifications(System::String ^ connectionString, System::String ^ table);
public static void EnableTableForNotifications (string connectionString, string table);
static member EnableTableForNotifications : string * string -> unit
Public Shared Sub EnableTableForNotifications (connectionString As String, table As String)

參數

connectionString
String

用來連接 SQL Server 資料庫的連接字串。

table
String

要啟用變更告知的資料庫資料表。

例外狀況

資料庫未啟用變更告知。

tablenull

無法建立與資料庫的連接。

-或-

ASP.NET 應用程式的安全性內容無權連接到資料庫。

-或-

ASP.NET 應用程式的安全性內容無權停用資料庫的告知。

範例

下列程式碼範例會 EnableTableForNotifications 使用 方法,在連接字串 MyConnectionString 中指定的資料庫中啟用指定資料表上的變更通知。

如需執行範例所需的完整程式碼,請參閱類別概觀主題的 SqlCacheDependencyAdmin 範例一節。

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

備註

方法 EnableTableForNotifications 會為 參數中指定的 table 資料表新增變更通知,該資料表必須位於 參數中指定的 connectionString 資料庫中。

當您使用 EnableTableForNotifications 方法將變更通知新增至資料表之後,如果您想要停用變更通知,則必須使用其中 DisableTableForNotifications 一個多載。

適用於

EnableTableForNotifications(String, String[])

連接到指定的 SQL Server 資料庫,並啟用指定資料庫資料表陣列的 SqlCacheDependency 變更告知。

public:
 static void EnableTableForNotifications(System::String ^ connectionString, cli::array <System::String ^> ^ tables);
public static void EnableTableForNotifications (string connectionString, string[] tables);
static member EnableTableForNotifications : string * string[] -> unit
Public Shared Sub EnableTableForNotifications (connectionString As String, tables As String())

參數

connectionString
String

用來連接 SQL Server 資料庫的連接字串。

tables
String[]

要啟用變更告知的 SQL Server 資料庫資料表陣列。

例外狀況

資料庫未啟用變更告知。

tables 參數中的其中一個值為 null

-或-

tables 參數中的其中一個值為空字串 ("")。

tablesnull

無法建立與資料庫的連接。

-或-

ASP.NET 應用程式的安全性內容無權連接到資料庫。

-或-

ASP.NET 應用程式的安全性內容無權停用資料庫的告知。

範例

下列程式碼範例會 EnableTableForNotifications 使用 方法,在連接字串 MyConnectionString 中指定的資料庫中,于以分號分隔的清單中指定的資料表上啟用變更通知。

如需執行範例所需的完整程式碼,請參閱類別概觀主題的 SqlCacheDependencyAdmin 範例一節。

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

備註

方法 EnableTableForNotifications 會為 參數中指定的 tables 資料表新增變更通知。 這些資料表必須位於 參數中指定的 connectionString 資料庫中。

當您使用 EnableTableForNotifications 方法將變更通知新增至資料表群組之後,如果您想要停用變更通知,則必須使用其中 DisableTableForNotifications 一個多載。

適用於