SqlCacheDependencyAdmin.EnableNotifications(String) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定したデータベース 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 メソッドを実行する必要があります。