Partager via


OdbcConnectionStringBuilder.ContainsKey(String) Méthode

Définition

Détermine si OdbcConnectionStringBuilder contient une clé spécifique.

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

Paramètres

keyword
String

Clé à rechercher dans OdbcConnectionStringBuilder.

Retours

true si OdbcConnectionStringBuilder contient un élément qui possède la clé spécifiée ; sinon, false.

Exceptions

keyword est null (Nothing en Visual Basic).

Exemples

L’exemple suivant crée une OdbcConnectionStringBuilder instance, définit certaines de ses propriétés, puis tente de déterminer si différentes clés existent dans l’objet en appelant la ContainsKey méthode .

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

S’applique à

Voir aussi