DbConnectionStringBuilder.ContainsKey(String) Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Bestimmt, ob die DbConnectionStringBuilder einen bestimmten Schlüssel enthält.
public:
virtual bool ContainsKey(System::String ^ keyword);
public virtual bool ContainsKey(string keyword);
abstract member ContainsKey : string -> bool
override this.ContainsKey : string -> bool
Public Overridable Function ContainsKey (keyword As String) As Boolean
Parameter
- keyword
- String
Der Schlüssel, der in der DbConnectionStringBuilderDatei gefunden werden soll.
Gibt zurück
true wenn der DbConnectionStringBuilder Eintrag mit dem angegebenen Schlüssel enthalten ist; andernfalls false.
Ausnahmen
keyword ist ein Nullverweis (Nothing in Visual Basic).
Beispiele
static void Main()
{
DbConnectionStringBuilder builder = new DbConnectionStringBuilder();
builder.Add("Provider", "Provider=Microsoft.Jet.OLEDB.4.0");
builder.Add("Data Source", "C:\\ThisExcelWorkbook.xls");
builder.Add("Extended Properties", "Excel 8.0;HDR=Yes;IMEX=1");
// Displays the values in the DbConnectionStringBuilder.
Console.WriteLine("Contents of the DbConnectionStringBuilder:");
Console.WriteLine(builder.ConnectionString);
// Searches for a key.
if (builder.ContainsKey("Data Source"))
{
Console.WriteLine("The collection contains the key \"Data Source\".");
}
else
{
Console.WriteLine("The collection does not contain the key \"Data Source\".");
}
Console.ReadLine();
}
Sub Main()
' The following code example searches for an element in a
' DbConnectionStringBuilder.
Dim builder As New DbConnectionStringBuilder
builder.Add("Provider", "Provider=Microsoft.Jet.OLEDB.4.0")
builder.Add("Data Source", "C:\ThisExcelWorkbook.xls")
builder.Add("Extended Properties", "Excel 8.0;HDR=Yes;IMEX=1")
' Displays the values in the DbConnectionStringBuilder.
Console.WriteLine("Contents of the DbConnectionStringBuilder:")
Console.WriteLine(builder.ConnectionString)
' Searches for a key.
If builder.ContainsKey("Data Source") Then
Console.WriteLine("The collection contains the key ""Data Source"".")
Else
Console.WriteLine("The collection does not contain the key ""Data Source"".")
End If
Console.ReadLine()
End Sub
Mit diesem Code wird die folgende Ausgabe generiert:
Contents of the DbConnectionStringBuilder:
provider="Provider=Microsoft.Jet.OLEDB.4.0";data
source=C:\MyExcel.xls;extended
properties="Excel 8.0;HDR=Yes;IMEX=1"
The collection contains the key "Data Source".