Freigeben über


OdbcConnectionStringBuilder.ContainsKey(String) Methode

Definition

Stellt fest, ob der OdbcConnectionStringBuilder einen bestimmten Schlüssel enthält.

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

Parameter

keyword
String

Der im OdbcConnectionStringBuilder zu suchende Schlüssel.

Gibt zurück

true, wenn OdbcConnectionStringBuilder ein Element mit dem angegebenen Schlüssel enthält, andernfalls false.

Ausnahmen

keyword ist NULL (Nothing in Visual Basic).

Beispiele

Im folgenden Beispiel wird ein OdbcConnectionStringBuilder instance erstellt, einige seiner Eigenschaften festgelegt und anschließend versucht, zu ermitteln, ob verschiedene Schlüssel innerhalb des Objekts vorhanden sind, indem die ContainsKey -Methode aufgerufen wird.

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

Gilt für:

Weitere Informationen