ConnectionStringsSectionとは? わかりやすく解説

ConnectionStringsSection クラス

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

接続文字列に関する構成ファイル セクションプログラムかアクセスできるようにします。

名前空間: System.Configuration
アセンブリ: System.Configuration (system.configuration.dll 内)
構文構文

Public NotInheritable Class
 ConnectionStringsSection
    Inherits ConfigurationSection
Dim instance As ConnectionStringsSection
public sealed class ConnectionStringsSection
 : ConfigurationSection
public ref class ConnectionStringsSection sealed
 : public ConfigurationSection
public final class ConnectionStringsSection
 extends ConfigurationSection
public final class ConnectionStringsSection
 extends ConfigurationSection
解説解説
使用例使用例

ConnectionStringsSection使用する方法の例を次に示します

' Create a connectionn string element and add it to
' the connection strings section.
Shared Sub New() 

    ' Get the application configuration file.
    Dim config _
    As System.Configuration.Configuration = _
    ConfigurationManager.OpenExeConfiguration( _
    ConfigurationUserLevel.None)
    
    ' Get the current connection strings count.
    Dim connStrCnt As Integer
 = _
    ConfigurationManager.ConnectionStrings.Count
    
    ' Create the connection string name. 
    Dim csName As String
 = "ConnStr" + connStrCnt.ToString()
    
    ' Create a connection string element and
    ' save it to the configuration file.
    ' Create a connection string element.
    Dim csSettings _
    As New ConnectionStringSettings( _
    csName, _
    "LocalSqlServer: data source=127.0.0.1;Integrated Security=SSPI;"
 + _
    "Initial Catalog=aspnetdb", "System.Data.SqlClient")
    
    ' Get the connection strings section.
    Dim csSection _
    As ConnectionStringsSection = _
    config.ConnectionStrings
    
    ' Add the new element.
    csSection.ConnectionStrings.Add(csSettings)
    
    ' Save the configuration file.
    config.Save(ConfigurationSaveMode.Modified)

End Sub 'New
 
// Create a connectionn string element and add it to
// the connection strings section.
static ConnectionStrings()
{
    // Get the application configuration file.
    System.Configuration.Configuration config =
            ConfigurationManager.OpenExeConfiguration(
            ConfigurationUserLevel.None);

    // Get the current connection strings count.
    int connStrCnt = 
        ConfigurationManager.ConnectionStrings.Count;
 
    // Create the connection string name. 
    string csName = 
        "ConnStr" + connStrCnt.ToString();

    // Create a connection string element and
    // save it to the configuration file.
   
    // Create a connection string element.
    ConnectionStringSettings csSettings =
            new ConnectionStringSettings(csName,
            "LocalSqlServer: data source=127.0.0.1;Integrated Security=SSPI;"
 +
            "Initial Catalog=aspnetdb", "System.Data.SqlClient");

    // Get the connection strings section.
    ConnectionStringsSection csSection =
        config.ConnectionStrings;

    // Add the new element.
    csSection.ConnectionStrings.Add(csSettings);
        
    // Save the configuration file.
    config.Save(ConfigurationSaveMode.Modified);
    
}

前述の例で使用されている構成抜粋次に示します

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="ConnStr1" connectionString="LocalSqlServer: data source=127.0.0.1;Integrated
 Security=SSPI;Initial Catalog=aspnetdb"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>
継承階層継承階層
System.Object
   System.Configuration.ConfigurationElement
     System.Configuration.ConfigurationSection
      System.Configuration.ConnectionStringsSection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ConnectionStringsSection メンバ
System.Configuration 名前空間
ConnectionStringSettingsCollection クラス
ConnectionStringSettings クラス
その他の技術情報
connectionStrings 要素 (ASP.NET 設定スキーマ)

ConnectionStringsSection コンストラクタ


ConnectionStringsSection プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ ConnectionStrings ConnectionStringSettings オブジェクトの ConnectionStringSettingsCollection コレクション取得します
パブリック プロパティ ElementInformation  ConfigurationElement オブジェクトカスタマイズできない情報機能格納する ElementInformation オブジェクト取得します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ LockAllAttributesExcept  ロックされている属性コレクション取得します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ LockAllElementsExcept  ロックされている要素コレクション取得します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ LockAttributes  ロックされている属性コレクション取得します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ LockElements  ロックされている要素コレクション取得します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ LockItem  要素ロックされているかどうかを示す値を取得または設定します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ SectionInformation  ConfigurationSection オブジェクトカスタマイズできない情報機能格納する SectionInformation オブジェクト取得します。 ( ConfigurationSection から継承されます。)
参照参照

関連項目

ConnectionStringsSection クラス
System.Configuration 名前空間
ConnectionStringSettingsCollection クラス
ConnectionStringSettings クラス

その他の技術情報

connectionStrings 要素 (ASP.NET 設定スキーマ)

ConnectionStringsSection メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

ConnectionStringsSection クラス
System.Configuration 名前空間
ConnectionStringSettingsCollection クラス
ConnectionStringSettings クラス

その他の技術情報

connectionStrings 要素 (ASP.NET 設定スキーマ)

ConnectionStringsSection メンバ

接続文字列に関する構成ファイル セクションプログラムかアクセスできるようにします。

ConnectionStringsSection データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド ConnectionStringsSection ConnectionStringsSection クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ ConnectionStrings ConnectionStringSettings オブジェクトの ConnectionStringSettingsCollection コレクション取得します
パブリック プロパティ ElementInformation  ConfigurationElement オブジェクトカスタマイズできない情報機能格納する ElementInformation オブジェクト取得します。 (ConfigurationElement から継承されます。)
パブリック プロパティ LockAllAttributesExcept  ロックされている属性コレクション取得します。(ConfigurationElement から継承されます。)
パブリック プロパティ LockAllElementsExcept  ロックされている要素コレクション取得します。(ConfigurationElement から継承されます。)
パブリック プロパティ LockAttributes  ロックされている属性コレクション取得します。 (ConfigurationElement から継承されます。)
パブリック プロパティ LockElements  ロックされている要素コレクション取得します。(ConfigurationElement から継承されます。)
パブリック プロパティ LockItem  要素ロックされているかどうかを示す値を取得または設定します。(ConfigurationElement から継承されます。)
パブリック プロパティ SectionInformation  ConfigurationSection オブジェクトカスタマイズできない情報機能格納する SectionInformation オブジェクト取得します。 (ConfigurationSection から継承されます。)
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

ConnectionStringsSection クラス
System.Configuration 名前空間
ConnectionStringSettingsCollection クラス
ConnectionStringSettings クラス

その他の技術情報

connectionStrings 要素 (ASP.NET 設定スキーマ)


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

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

辞書ショートカット

すべての辞書の索引

「ConnectionStringsSection」の関連用語

ConnectionStringsSectionのお隣キーワード
検索ランキング

   

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



ConnectionStringsSectionのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS