SqlCacheDependency コンストラクタとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SqlCacheDependency コンストラクタの意味・解説 

SqlCacheDependency コンストラクタ (String, String)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

SqlCacheDependency クラス新しインスタンス初期化し指定されているパラメータ使用してキャッシュ キー依存関係作成します

名前空間: System.Web.Caching
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Sub New ( _
    databaseEntryName As String, _
    tableName As String _
)
Dim databaseEntryName As String
Dim tableName As String

Dim instance As New SqlCacheDependency(databaseEntryName,
 tableName)
public SqlCacheDependency (
    string databaseEntryName,
    string tableName
)
public:
SqlCacheDependency (
    String^ databaseEntryName, 
    String^ tableName
)
public SqlCacheDependency (
    String databaseEntryName, 
    String tableName
)
public function SqlCacheDependency (
    databaseEntryName : String, 
    tableName : String
)

パラメータ

databaseEntryName

アプリケーションの Web.config ファイルcaching の sqlCacheDependency の databases 要素 (ASP.NET 設定スキーマ) 要素定義されているデータベースの名前。

tableName

SqlCacheDependency が関連付けられているデータベース テーブルの名前。

例外例外
例外種類条件

HttpException

SqlClientPermission の内部検証失敗しました

または

テーブル ベース通知用に設定されているデータベースの一覧に databaseEntryName がありませんでした

または

初期化時に SqlCacheDependency オブジェクトデータベース接続できませんでした

または

SqlCacheDependency オブジェクトサポートするデータベース ストアド プロシージャまたはデータベースいずれかで、SqlCacheDependency オブジェクト権限拒否エラー検出しました

ArgumentException

tableName パラメータが String.Empty です。

ConfigurationErrorsException

SqlCacheDependencyポーリング有効になっていません。

または

ポーリング間隔正しく設定されていません。

または

アプリケーション構成ファイル接続文字列指定されませんでした

または

アプリケーション構成ファイル指定されている接続文字列が見つかりませんでした

または

アプリケーション構成ファイル指定されている接続文字列空の文字列です。

DatabaseNotEnabledForNotificationException

databaseEntryName パラメータ指定されているデータベース変更通知有効になっていません。

TableNotEnabledForNotificationException

tableName パラメータ指定されているデータベース テーブル変更通知有効になっていません。

ArgumentNullException

databaseEntryNamenull 参照 (Visual Basic では Nothing) です。

または

tableNamenull 参照 (Visual Basic では Nothing) です。

解説解説

このコンストラクタ使用してSQL Server 7 製品および SQL Server 2000 製品SqlCacheDependency オブジェクト作成します

database パラメータ渡されるデータベース名は、アプリケーションの Web.config ファイル定義されている必要があります。例として、pubs というデータベースSqlCacheDependency 変更通知定義する Web.config ファイル次に示します

<configuration>
  <connectionStrings>
    <add name="Pubs" connectionString="Data Source=(local); Initial Catalog=pubs;
 Integrated Security=true"; providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <caching>
      <sqlCacheDependency enabled = "true" pollTime = "60000" >
        <databases>
          <add name="pubs" 
            connectionString = "pubs"
            pollTime = "9000000"
            />
        </databases>
      </sqlCacheDependency>
    </caching>
  </system.web>
</configuration>

このコンストラクタ使用する場合は、DatabaseNotEnabledForNotificationException および TableNotEnabledForNotificationException という 2 つ例外スローされるのが一般的です。DatabaseNotEnabledForNotificationExceptionスローされた場合は、例外処理コードで SqlCacheDependencyAdmin.EnableNotifications メソッド呼び出すか、コマンド ライン ツールの Aspnet_regsql.exe を使用してデータベース通知設定しますTableNotEnabledForNotificationExceptionスローされた場合は、SqlCacheDependencyAdmin.EnableTableForNotifications メソッド呼び出すか、Aspnet_regsql.exe を使用してテーブル通知設定します

使用例使用例

このコンストラクタ使用してSQL Server データベース (Northwind) のデータベース テーブル (Categories) に関連付けられている SqlCacheDependency クラスインスタンス作成するコード例次に示します

Sub Page_Load(Src As Object,
 E As EventArgs)
   ' Declare the SqlCacheDependency instance, SqlDep.
   Dim SqlDep As SqlCacheDependency

   ' Check the Cache for the SqlSource key.
   ' If it isn't there, create it with a dependency
   ' on a SQL Server table using the SqlCacheDependency class.
   If Cache("SqlSource") Is
 Nothing

      ' Because of possible exceptions thrown when this
      ' code runs, use Try...Catch...Finally syntax.
      Try
         ' Instantiate SqlDep using the SqlCacheDependency constructor.
         SqlDep = New SqlCacheDependency("Northwind",
 "Categories")

      ' Handle the DatabaseNotEnabledForNotificationException with
      ' a call to the SqlCacheDependencyAdmin.EnableNotifications method.
      Catch exDBDis As DatabaseNotEnabledForNotificationException
         Try
            SqlCacheDependencyAdmin.EnableNotifications("Northwind")

         ' If the database does not have permissions set for creating
 tables,
         ' the UnauthorizedAccessException is thrown. Handle it by redirecting
         ' to an error page.
         Catch exPerm As UnauthorizedAccessException
             Response.Redirect(".\ErrorPage.htm")
         End Try

      ' Handle the TableNotEnabledForNotificationException with
            ' a call to the SqlCacheDependencyAdmin.EnableTableForNotifications
 method.
      Catch exTabDis As TableNotEnabledForNotificationException
         Try
            SqlCacheDependencyAdmin.EnableTableForNotifications( _
             "Northwind", "Categories")

         ' If a SqlException is thrown, redirect to an error page.
         Catch exc As SqlException
             Response.Redirect(".\ErrorPage.htm")
         End Try

      ' If all the other code is successful, add MySource to the Cache
      ' with a dependency on SqlDep. If the Categories table changes
,
      ' MySource will be removed from the Cache. Then generate a message
            ' that the data is newly created and added to the cache.
      Finally
         Cache.Insert("SqlSource", Source1, SqlDep)
            CacheMsg.Text = "The data object was created explicitly."

      End Try

    Else
       CacheMsg.Text = "The data was retrieved from the Cache."
    End If
End Sub
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SqlCacheDependency クラス
SqlCacheDependency メンバ
System.Web.Caching 名前空間
SqlCacheDependency

SqlCacheDependency コンストラクタ (SqlCommand)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

SqlCacheDependency クラス新しインスタンス初期化し指定されている SqlCommand使用してキャッシュ キー依存関係作成します

名前空間: System.Web.Caching
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Sub New ( _
    sqlCmd As SqlCommand _
)
Dim sqlCmd As SqlCommand

Dim instance As New SqlCacheDependency(sqlCmd)
public SqlCacheDependency (
    SqlCommand sqlCmd
)
public:
SqlCacheDependency (
    SqlCommand^ sqlCmd
)
public SqlCacheDependency (
    SqlCommand sqlCmd
)
public function SqlCacheDependency (
    sqlCmd : SqlCommand
)

パラメータ

sqlCmd

SqlCacheDependency オブジェクト作成するために使用する SqlCommand。

例外例外
例外種類条件

ArgumentNullException

sqlCmd パラメータnull 参照 (Visual Basic では Nothing) です。

HttpException

SqlCommand インスタンスの NotificationAutoEnlist プロパティtrue設定されページには SqlDependency 属性CommandNotification設定された @ OutputCache ディレクティブあります

解説解説

このコンストラクタは、SQL Server 2005 製品クエリ通知機能使用する SqlCacheDependency オブジェクトの作成使用します

sqlCommand パラメータ関連付けられている SQL ステートメントには、次の要素含まれる必要があります

このコンストラクタによって、SQL Server 2005クエリ通知使用してページ レベル出力キャッシュを行うページ上の SqlCacheDependency インスタンスSqlCommand インスタンス関連付けることはできません。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SqlCacheDependency クラス
SqlCacheDependency メンバ
System.Web.Caching 名前空間
SqlCacheDependency

SqlCacheDependency コンストラクタ

SqlCacheDependency クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
SqlCacheDependency (SqlCommand) SqlCacheDependency クラス新しインスタンス初期化し指定されている SqlCommand を使用してキャッシュ キー依存関係作成します
SqlCacheDependency (String, String) SqlCacheDependency クラス新しインスタンス初期化し指定されているパラメータ使用してキャッシュ キー依存関係作成します
参照参照

関連項目

SqlCacheDependency クラス
SqlCacheDependency メンバ
System.Web.Caching 名前空間
SqlCacheDependency


このページでは「.NET Framework クラス ライブラリ リファレンス」からSqlCacheDependency コンストラクタを検索した結果を表示しています。
Weblioに収録されているすべての辞書からSqlCacheDependency コンストラクタを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からSqlCacheDependency コンストラクタ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「SqlCacheDependency コンストラクタ」の関連用語

SqlCacheDependency コンストラクタのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SqlCacheDependency コンストラクタのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS