SqlConnectionStringBuilder.Keys 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 ICollection 中包含索引鍵的 SqlConnectionStringBuilder。
public:
virtual property System::Collections::ICollection ^ Keys { System::Collections::ICollection ^ get(); };
public override System.Collections.ICollection Keys { get; }
member this.Keys : System.Collections.ICollection
Public Overrides ReadOnly Property Keys As ICollection
屬性值
ICollection 中包含索引鍵的 SqlConnectionStringBuilder。
範例
下列主控台應用程式範例會建立新的 SqlConnectionStringBuilder。 此程式碼會針對 ICollection 屬性傳回的 Keys 執行迴圈,以顯示索引鍵/值組。
using System.Data.SqlClient;
class Program
{
static void Main()
{
SqlConnectionStringBuilder builder =
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:
foreach (string key in builder.Keys)
Console.WriteLine("{0}={1}", key, builder[key]);
Console.WriteLine();
Console.WriteLine("Press Enter to continue.");
Console.ReadLine();
}
}
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
備註
雖然 ICollection 中值的順序並未指定,但此順序會與 ICollection 屬性傳回之 Values 中關聯值的順序相同。
適用於
另請參閱
- Values
- Item[String]
- ADO.NET 中的連接字串
- ADO.NET 概觀 \(部分機器翻譯\)