Share via


SqlCacheDependencyAdmin.EnableNotifications(String) メソッド

定義

指定されているデータベースの SqlCacheDependency 変更通知を有効にします。

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

パラメーター

connectionString
String

SQL Server データベースに接続するときに使用する接続文字列。

例外

データベースへの接続を確立できませんでした。

- または -

ASP.NET アプリケーションのセキュリティ コンテキストに、データベースに接続できる権限がありません。

- または -

ASP.NET アプリケーションのセキュリティ コンテキストに、データベースの通知を無効にできる権限がありません。

次のコード例では、 メソッドを EnableNotifications 使用して、接続文字列 MyConnectionStringで指定されたデータベースの変更通知を有効にします。

この例を実行するために必要な完全なコードについては、クラスの概要に関するトピックの「例」セクションを SqlCacheDependencyAdmin 参照してください。

protected void enableNotification_Click(object sender, EventArgs e)
{
  SqlCacheDependencyAdmin.EnableNotifications(
    ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString);
}
Protected Sub enableNotification_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  SqlCacheDependencyAdmin.EnableNotifications( _
      ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString)
End Sub

注釈

メソッドは EnableNotifications 、 パラメーターで指定されたデータベースからの変更通知のサポートを connectionString 追加します。 メソッドを実行したら、データベースの EnableNotifications 変更通知を DisableNotifications 無効にする場合は、 メソッドを実行する必要があります。

適用対象