OdbcConnectionStringBuilder.Item[String] Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Belirtilen anahtarla ilişkili değeri alır veya ayarlar. C# dilinde bu özellik dizin oluşturucudur.
public:
virtual property System::Object ^ default[System::String ^] { System::Object ^ get(System::String ^ keyword); void set(System::String ^ keyword, System::Object ^ value); };
public override object this[string keyword] { get; set; }
member this.Item(string) : obj with get, set
Default Public Overrides Property Item(keyword As String) As Object
Parametreler
- keyword
- String
Alınacak veya ayarlanacağı öğenin anahtarı.
Özellik Değeri
Belirtilen anahtarla ilişkili değer.
Özel durumlar
bağlantı dizesi yanlış biçimlendirildi (anahtar/değer çiftinde gerekli "=" eksik olabilir).
keyword
bir null başvurudur (Nothing
Visual Basic'te).
Örnekler
Aşağıdaki kod, bir konsol uygulamasında yeni OdbcConnectionStringBuilder bir oluşturur ve özelliğini kullanarak bağlantı dizesi anahtar/değer çiftleri Item[] ekler.
using System.Data.Odbc;
class Program
{
static void Main()
{
OdbcConnectionStringBuilder builder =
new OdbcConnectionStringBuilder();
// Set up a connection string for a text file.
builder["Driver"] = "Microsoft Text Driver (*.txt; *.csv)";
builder["dbq"] = "C:\\TextFilesFolder";
builder["Extension"] = "asc,csv,tab,txt";
// Overwrite the existing value for the dbq value,
// because it already exists within the collection.
builder["dbq"] = "D:\\";
Console.WriteLine(builder.ConnectionString);
Console.WriteLine();
Console.WriteLine("Press Enter to continue.");
Console.ReadLine();
}
}
Imports System.Data.Odbc
Module Module1
Sub Main()
Dim builder As New OdbcConnectionStringBuilder
' Set up a connection string for a text file.
builder.Item("Driver") = "Microsoft Text Driver (*.txt; *.csv)"
' Note that Item is the default property, so
' you need not include it in the reference.
builder("dbq") = "C:\TextFilesFolder"
builder.Item("Extension") = "asc,csv,tab,txt"
' Overwrite the existing value for the dbq value,
' because it already exists within the collection.
builder.Item("dbq") = "D:\"
Console.WriteLine(builder.ConnectionString)
Console.WriteLine()
Console.WriteLine("Press Enter to continue.")
Console.ReadLine()
End Sub
End Module
Açıklamalar
Bu özelliği ayarladığınızda, belirtilen anahtar sözlükte zaten varsa, değer değiştirilir; aksi takdirde, yeni bir öğe oluşturulur.