SqlConnectionStringBuilder.Item[String] 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 키와 연결된 값을 가져오거나 설정합니다. C#에서 이 속성은 인덱서입니다.
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
매개 변수
- keyword
- String
가져오기 또는 설정할 항목의 키입니다.
속성 값
지정된 키와 연결된 값입니다.
예외
keyword null 참조입니다(Visual Basic Nothing).
사용 가능한 키 내에 존재하지 않는 키를 추가하려고 했습니다.
연결 문자열 내의 값이 잘못되었습니다(특히 부울 또는 숫자 값이 예상되었지만 제공되지 않음).
예제
콘솔 애플리케이션에서 다음 코드는 새 SqlConnectionStringBuilder 만들고 Item[] 속성을 사용하여 연결 문자열 키/값 쌍을 추가합니다.
class Program
{
static void Main()
{
SqlConnectionStringBuilder builder =
new SqlConnectionStringBuilder();
builder["Data Source"] = "(local)";
builder["Integrated Security"] = true;
builder["Initial Catalog"] = "AdventureWorks";
// Overwrite the existing value for the Data Source value.
builder["Data Source"] = ".";
Console.WriteLine(builder.ConnectionString);
Console.WriteLine();
Console.WriteLine("Press Enter to continue.");
Console.ReadLine();
}
}
Module Module1
Sub Main()
Dim builder As New SqlConnectionStringBuilder
builder.Item("Data Source") = "(local)"
' Item is the default property, so
' you needn't include it in the reference.
builder("Integrated Security") = True
builder.Item("Initial Catalog") = "AdventureWorks"
' Overwrite the existing value for the Data Source value.
builder.Item("Data Source") = "."
Console.WriteLine(builder.ConnectionString)
Console.WriteLine()
Console.WriteLine("Press Enter to continue.")
Console.ReadLine()
End Sub
End Module
설명
SqlConnectionStringBuilder 고정 크기 사전이 포함되어 있으므로 사전 KeyNotFoundException내에 존재하지 않는 키를 추가하려고 하면 .