Share via


SqlCacheDependencyAdmin.DisableNotifications(String) 方法

定義

停用指定資料庫的 SqlCacheDependency 變更告知。

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

參數

connectionString
String

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

例外狀況

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

-或-

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

-或-

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

範例

下列程式碼範例會 DisableNotifications 使用 方法來停用連接字串 MyConnectionString 所指定資料庫的變更通知。

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

' Create a method to disable SqlCacheDependency
' change notifications for the Northwind database.
Public Sub DisableDatabase_Click( _
 sender As Object, e As System.EventArgs)

   SqlCacheDependencyAdmin.DisableNotifications( _
   "Northwind")
   Response.Write("Northwind database disabled at " _
   & DateTime.Now.ToString())

   ' An HttpException is thrown if adequate permissions to
   ' modify the database are not granted.

End Sub

備註

方法 DisableNotifications 會從 參數中指定的 connectionString 資料庫移除變更通知的支援。 DisableNotifications執行 方法之後,如果您想要重新啟用資料庫的變更通知,則必須執行 EnableNotifications 方法。

適用於