DbConnectionStringBuilder.Count 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 ConnectionString 屬性內所包含的索引鍵目前數目。
public:
virtual property int Count { int get(); };
public virtual int Count { get; }
[System.ComponentModel.Browsable(false)]
public virtual int Count { get; }
member this.Count : int
[<System.ComponentModel.Browsable(false)>]
member this.Count : int
Public Overridable ReadOnly Property Count As Integer
屬性值
包含在 DbConnectionStringBuilder 執行個體所維護之連接字串內的索引鍵數目。
實作
- 屬性
範例
下列範例示範 Count 在您修改屬性內容 ConnectionString 之前和之後的屬性。
static void Main()
{
DbConnectionStringBuilder builder = new DbConnectionStringBuilder();
builder.ConnectionString =
"Data Source=(local);Initial Catalog=AdventureWorks;" +
"Integrated Security=SSPI";
// This should display "3" in the console window.
Console.WriteLine("Original count: " + builder.Count);
builder.Add("Connection Timeout", 25);
// This should display the new connection string and
// the number of items (4) in the console window.
Console.WriteLine(builder.ConnectionString);
Console.WriteLine("New count: " + builder.Count);
Console.WriteLine();
Console.WriteLine("Press Enter to finish.");
Console.ReadLine();
}
Sub Main()
Dim builder As New DbConnectionStringBuilder
builder.ConnectionString = _
"Data Source=(local);Initial Catalog=AdventureWorks;" & _
"Integrated Security=SSPI"
' This should display "3" in the console window.
Console.WriteLine(builder.Count)
builder.Add("Connection Timeout", 25)
' This should display the new connection string and
' the number of items (4) in the console window.
Console.WriteLine(builder.ConnectionString)
Console.WriteLine(builder.Count)
Console.WriteLine()
Console.WriteLine("Press Enter to finish.")
Console.ReadLine()
End Sub
適用於
另請參閱
- ADO.NET 中的連接字串
- ADO.NET 概觀 \(部分機器翻譯\)