<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Default_aspx" %>
Untitled Page
File: Default.aspx.vb
Partial Class Default_aspx
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
EnableNotification("Authors")
End Sub
Public Sub EnableNotification(ByVal tableName As String)
Dim connStr As String = "Server=.\SQLEXPRESS;Integrated Security=True;Database=pubs;Persist Security Info=True"
Dim mustEnable As Boolean = True
Try
Dim tablesEnabled() As String
tablesEnabled = _
SqlCacheDependencyAdmin.GetTablesEnabledForNotifications(connStr)
If (tablesEnabled IsNot Nothing) Then
Dim table As String
Response.Write("Tables Enabled For " & _
"Notification
")
For Each table In tablesEnabled
Response.Write(table & "
")
If (table.ToString.Equals(tableName)) Then
mustEnable = False
End If
Next
End If
Catch ex As Exception
mustEnable = True
End Try
If mustEnable Then
SqlCacheDependencyAdmin.EnableNotifications(connStr)
SqlCacheDependencyAdmin. _
EnableTableForNotifications(connStr, tableName)
Response.Write(tableName & "
")
End If
End Sub
End Class