OdbcConnectionStringBuilder.ContainsKey(String) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Determines whether the OdbcConnectionStringBuilder contains a specific key.
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
- keyword
- String
The key to locate in the OdbcConnectionStringBuilder.
true
if the OdbcConnectionStringBuilder contains an element that has the specified key; otherwise false
.
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();
}
}
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
Продукт | Версии |
---|---|
.NET | 8 (package-provided), 9 (package-provided), 10 (package-provided) |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
Обратна връзка за .NET
.NET е проект с отворен код. Изберете връзка, за да предоставите обратна връзка: