SqlConnectionStringBuilder.Keys Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets an ICollection that contains the keys in the SqlConnectionStringBuilder.

Namespace:   System.Data.SqlClient
Assembly:  System.Data (in System.Data.dll)

Public Overrides ReadOnly Property Keys As ICollection

Property Value

Type: System.Collections.ICollection

An ICollection that contains the keys in the SqlConnectionStringBuilder.

The order of the values in the ICollection is unspecified, but it is the same order as the associated values in the ICollection returned by the Values property.

The following console application example creates a new SqlConnectionStringBuilder. The code loops through the ICollection returned by the Keys property displaying the key/value pairs.

Imports System.Data.SqlClient

Module Module1
    Sub Main()
        Dim builder As New SqlConnectionStringBuilder
        builder.DataSource = "(local)"
        builder.IntegratedSecurity = True
        builder.InitialCatalog = "AdventureWorks"

        ' Loop through the collection of keys, displaying 
        ' the key and value for each item.
        For Each key As String In builder.Keys
            Console.WriteLine("{0}={1}", key, builder(key))
        Next

        Console.WriteLine()
        Console.WriteLine("Press Enter to continue.")
        Console.ReadLine()
    End Sub
End Module

.NET Framework
Available since 2.0
Return to top
Show: