OdbcConnectionStringBuilder.Remove Method (String)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Removes the entry with the specified key from the OdbcConnectionStringBuilder instance.

Namespace:   System.Data.Odbc
Assembly:  System.Data (in System.Data.dll)

public override bool Remove(
	string keyword


Type: System.String

The key of the key/value pair to be removed from the connection string in this OdbcConnectionStringBuilder.

Return Value

Type: System.Boolean

true if the key existed within the connection string and was removed; false if the key did not exist.

Exception Condition

keyword is null (Nothing in Visual Basic).

Because the Remove method returns a value that indicates its success, it is not required to look for the existence of a key before trying to remove the key/value pair from the OdbcConnectionStringBuilder instance.

The following example creates an OdbcConnectionStringBuilder instance and demonstrates the behavior of the Remove method.

using System.Data.Odbc;

class Program
    static void Main()
        OdbcConnectionStringBuilder builder =
            new OdbcConnectionStringBuilder();
        builder.ConnectionString =
            "Driver={SQL Server};Server=(local);" +


        // Try to remove an existing item.
        TryRemove(builder, "Server");

        // Try to remove a nonexistent item.
        TryRemove(builder, "User ID");

        // Try to remove an existing item, 
        // demonstrating that the search is not 
        // case sensitive.
        TryRemove(builder, "DATABASE");

        Console.WriteLine("Press Enter to continue.");

    static void TryRemove(OdbcConnectionStringBuilder builder, 
        string itemToRemove)

        if (builder.Remove(itemToRemove))
            Console.WriteLine("Removed '{0}'", itemToRemove);
            Console.WriteLine("Unable to remove '{0}'", itemToRemove);

.NET Framework
Available since 2.0
Return to top