OdbcConnectionStringBuilder.Remove Method
.NET Framework 4
Removes the entry with the specified key from the OdbcConnectionStringBuilder instance.
Assembly: System.Data (in System.Data.dll)
Parameters
- 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.Booleantrue if the key existed within the connection string and was removed; false if the key did not exist.
| Exception | Condition |
|---|---|
| ArgumentNullException |
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);" + "Database=AdventureWorks;Trusted_Connection=yes;"; Console.WriteLine(builder.ConnectionString); // 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."); Console.ReadLine(); } static void TryRemove(OdbcConnectionStringBuilder builder, string itemToRemove) { if (builder.Remove(itemToRemove)) { Console.WriteLine("Removed '{0}'", itemToRemove); } else { Console.WriteLine("Unable to remove '{0}'", itemToRemove); } Console.WriteLine(builder.ConnectionString); } }
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.