SqlConnectionStringBuilder.DataSource 속성

정의

연결할 SQL Server 인스턴스의 이름이나 네트워크 주소를 가져오거나 설정합니다.

public:
 property System::String ^ DataSource { System::String ^ get(); void set(System::String ^ value); };
public string DataSource { get; set; }
[System.ComponentModel.TypeConverter(typeof(System.Data.SqlClient.SqlConnectionStringBuilder+SqlDataSourceConverter))]
public string DataSource { get; set; }
member this.DataSource : string with get, set
[<System.ComponentModel.TypeConverter(typeof(System.Data.SqlClient.SqlConnectionStringBuilder+SqlDataSourceConverter))>]
member this.DataSource : string with get, set
Public Property DataSource As String

속성 값

DataSource 속성의 값이거나, 제공된 값이 없으면 String.Empty입니다.

특성

예외

값을 null로 설정하려면 Value를 사용합니다.

예제

다음 예제에서는 SqlConnectionStringBuilder 클래스가 "Data Source" 연결 문자열 키의 동의어를 잘 알려진 키로 변환하는 것을 보여 줍니다.

using System.Data.SqlClient;

class Program
{
    static void Main()
    {
        SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(
            "Network Address=(local);Integrated Security=SSPI;" +
            "Initial Catalog=AdventureWorks");

        // Display the connection string, which should now
        // contain the "Data Source" key, as opposed to the
        // supplied "Network Address".
        Console.WriteLine(builder.ConnectionString);

        // Retrieve the DataSource property.
        Console.WriteLine("DataSource = " + builder.DataSource);

        Console.WriteLine("Press any key to continue.");
        Console.ReadLine();
    }
}
Imports System.Data.SqlClient

Module Module1

    Sub Main()
        Dim builder As _
         New SqlConnectionStringBuilder( _
         "Network Address=(local);Integrated Security=SSPI;" & _
         "Initial Catalog=AdventureWorks")

        ' Display the connection string, which should now 
        ' contain the "Data Source" key, as opposed to the 
        ' supplied "Network Address".
        Console.WriteLine(builder.ConnectionString)

        ' Retrieve the DataSource property:
        Console.WriteLine("DataSource = " & builder.DataSource)

        Console.WriteLine("Press any key to continue.")
        Console.ReadLine()
    End Sub
End Module

설명

이 속성은 연결 문자열 내의 "Data Source", "server", "address", "addr" 및 "network address" 키에 해당합니다. 제공된 된 연결 문자열 내에서 어떤이 값을 제공 하는 것에 관계 없이 연결 문자열에서 만든는 SqlConnectionStringBuilder 잘 알려진 "Data Source" 키를 사용 합니다.

적용 대상

추가 정보