OdbcConnectionStringBuilder.ContainsKey(String) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
判斷 OdbcConnectionStringBuilder 是否包含特定索引鍵。
public:
override bool ContainsKey(System::String ^ keyword);
public override bool ContainsKey (string keyword);
override this.ContainsKey : string -> bool
Public Overrides Function ContainsKey (keyword As String) As Boolean
參數
- keyword
- String
要在 OdbcConnectionStringBuilder 中尋找的索引鍵。
傳回
如果 OdbcConnectionStringBuilder 包含具有指定之索引鍵的項目,則為 true
,否則為 false
。
例外狀況
keyword
是 null (在 Visual Basic 中為 Nothing
)。
範例
下列範例會 OdbcConnectionStringBuilder 建立 實例、設定它的一些屬性,然後藉由呼叫 ContainsKey 方法來嘗試判斷物件中是否有各種索引鍵。
using System.Data.Odbc;
class Program
{
static void Main()
{
OdbcConnectionStringBuilder builder = new OdbcConnectionStringBuilder();
builder.Driver = "Microsoft Visual FoxPro Driver";
builder["SourceType"] = "DBC";
// Keys that you have provided return true.
Console.WriteLine(builder.ContainsKey("SourceType"));
// Comparison is case insensitive.
Console.WriteLine(builder.ContainsKey("sourcetype"));
// Keys added by the provider return false. This method
// only examines keys added explicitly.
Console.WriteLine(builder.ContainsKey("DNS"));
// Keys that do not exist return false.
Console.WriteLine(builder.ContainsKey("MyKey"));
Console.WriteLine("Press Enter to continue.");
Console.ReadLine();
}
}
Imports System.Data.Odbc
Module Module1
Sub Main()
Dim builder As New OdbcConnectionStringBuilder()
builder.Driver = "Microsoft Visual FoxPro Driver"
builder("SourceType") = "DBC"
' Keys you have provided return true.
Console.WriteLine(builder.ContainsKey("SourceType"))
' Comparison is case insensitive.
Console.WriteLine(builder.ContainsKey("sourcetype"))
' Keys added by the provider return false. This method
' only examines keys added explicitly.
Console.WriteLine(builder.ContainsKey("DNS"))
' Keys that do not exist return false.
Console.WriteLine(builder.ContainsKey("MyKey"))
Console.WriteLine("Press Enter to continue.")
Console.ReadLine()
End Sub
End Module