This topic has not yet been rated - Rate this topic

OdbcConnectionStringBuilder.ContainsKey Method

Determines whether the OdbcConnectionStringBuilder contains a specific key.

Namespace:  System.Data.Odbc
Assembly:  System.Data (in System.Data.dll)
public override bool ContainsKey(
	string keyword
)

Parameters

keyword
Type: System.String
The key to locate in the OdbcConnectionStringBuilder.

Return Value

Type: System.Boolean
true if the OdbcConnectionStringBuilder contains an element that has the specified key; otherwise false.
Exception Condition
ArgumentNullException

keyword is null (Nothing in Visual Basic).

The following example creates an OdbcConnectionStringBuilder instance, sets some of its properties, and then tries to determine whether various keys exist within the object by calling the ContainsKey method.


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();
    }
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ