本文整理匯總了VB.NET中System.Web.Caching.SqlCacheDependencyAdmin類的典型用法代碼示例。如果您正苦於以下問題:VB.NET SqlCacheDependencyAdmin類的具體用法?VB.NET SqlCacheDependencyAdmin怎麽用?VB.NET SqlCacheDependencyAdmin使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了SqlCacheDependencyAdmin類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: table
Partial Class cacheDependencyAdminvb
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
'Put the page into a default state.
enabledTables.Visible = True
disableTable.Visible = True
enabledTablesMsg.Text = "Tables enabled for change notification:"
tableName.Visible = True
enableTable.Visible = True
tableEnableMsg.Text = "Enable change notification on table(s):"
enableTableErrorMsg.Text = ""
End Sub
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs)
Try
Dim enabledTablesList As String()
enabledTablesList = SqlCacheDependencyAdmin.GetTablesEnabledForNotifications( _
ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString)
If enabledTablesList.Length > 0 Then
enabledTables.DataSource = enabledTablesList
enabledTables.DataBind()
Else
enabledTablesMsg.Text = "No tables are enabled for change notifications."
enabledTables.Visible = False
disableTable.Visible = False
End If
Catch ex As DatabaseNotEnabledForNotificationException
enabledTables.Visible = False
disableTable.Visible = False
enabledTablesMsg.Text = "Cache notifications are not enabled in this database."
tableName.Visible = False
enableTable.Visible = False
tableEnableMsg.Text = "Must enable database for notifications before enabling tables."
End Try
End Sub
Protected Sub enableNotification_Click(ByVal sender As Object, ByVal e As System.EventArgs)
SqlCacheDependencyAdmin.EnableNotifications( _
ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString)
End Sub
Protected Sub disableNotification_Click(ByVal sender As Object, ByVal e As System.EventArgs)
SqlCacheDependencyAdmin.DisableNotifications( _
ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString)
End Sub
Protected Sub disableTable_Click(ByVal sender As Object, ByVal e As System.EventArgs)
For Each item As ListItem In enabledTables.Items
If item.Selected Then
SqlCacheDependencyAdmin.DisableTableForNotifications( _
ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString, _
item.Text)
End If
Next
End Sub
Protected Sub enableTable_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Try
If tableName.Text.Contains(";") Then
Dim tables As String()
tables = tableName.Text.Split(New [Char]() {";"c})
For i As Integer = 0 To tables.Length - 1
tables(i) = tables(i).Trim
Next
SqlCacheDependencyAdmin.EnableTableForNotifications( _
ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString, _
tables)
Else
SqlCacheDependencyAdmin.EnableTableForNotifications( _
ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString, _
tableName.Text)
End If
Catch ex As HttpException
enableTableErrorMsg.Text = "<br />" & _
"An error occurred enabling a table.<br />" & _
"The error message was: " & _
ex.Message
enableTableErrorMsg.Visible = True
End Try
End Sub
End Class