DbConnectionStringBuilder.Keys プロパティ
アセンブリ: System.Data (system.data.dll 内)

DbConnectionStringBuilder 内のキーを格納している ICollection。

ICollection に格納される値の順序は不定ですが、Values プロパティから返される ICollection 内の、対応する値と同じ順序になります。
返される ICollection は静的なコピーではありません。代わりに、この ICollection は、元の DbConnectionStringBuilder のキーを参照します。そのため、DbConnectionStringBuilder に対する変更は、ICollection に反映されます。

新しい DbConnectionStringBuilder を作成してキーを追加するコンソール アプリケーションの例を次に示します。このコードでは、Keys プロパティから返された ICollection をループ処理しながらキー/値ペアを表示した後、新しいキーを追加します。Keys プロパティは動的な ICollection を返すため、2 番目のループでは最新のキー/値ペアを含むすべてのキー/値ペアを表示します。
Sub Main() Dim builder As New DbConnectionStringBuilder builder("Data Source") = "(local)" builder("integrated security") = True builder("Initial Catalog") = "AdventureWorks;NewValue=Bad" ' Obtain reference to the collection of keys. Dim keys As ICollection = builder.Keys Console.WriteLine("Keys before adding TimeOut:") For Each key As String In keys Console.WriteLine("{0}={1}", key, builder(key)) Next ' Add a new item to the collection. builder("Timeout") = 300 Console.WriteLine() Console.WriteLine("Keys after adding TimeOut:") ' Because the Keys property is dynamically updated, ' the following loop includes the Timeout key. For Each key As String In keys Console.WriteLine("{0}={1}", key, builder(key)) Next Console.WriteLine() Console.WriteLine("Press Enter to continue.") Console.ReadLine() End Sub
static void Main() { DbConnectionStringBuilder builder = new DbConnectionStringBuilder(); builder["Data Source"] = "(local)"; builder["Integrated Security"] = true; builder["Initial Catalog"] = "AdventureWorks"; // Obtain reference to the collection of keys. ICollection keys = builder.Keys; Console.WriteLine("Keys before adding TimeOut:"); foreach (string key in keys) Console.WriteLine("{0}={1}", key, builder[key]); // Add a new item to the collection. builder["Timeout"] = 300; Console.WriteLine(); Console.WriteLine("Keys after adding TimeOut:"); // Because the Keys property is dynamically updated, // the following loop includes the Timeout key. foreach (string key in keys) Console.WriteLine("{0}={1}", key, builder[key]); Console.WriteLine(); Console.WriteLine("Press Enter to continue."); Console.ReadLine(); }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からDbConnectionStringBuilder.Keys プロパティを検索する場合は、下記のリンクをクリックしてください。

- DbConnectionStringBuilder.Keys プロパティのページへのリンク