SqlConnectionStringBuilder.DataSource 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
연결할 SQL Server 인스턴스의 이름 또는 네트워크 주소를 가져오거나 설정합니다.
public:
property System::String ^ DataSource { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.TypeConverter(typeof(System.Data.SqlClient.SqlConnectionStringBuilder+SqlDataSourceConverter))]
public string DataSource { 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 클래스가 "데이터 원본" 연결 문자열 키의 동의어를 잘 알려진 키로 변환하는 방법을 보여 줍니다.
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
설명
이 속성은 연결 문자열 내의 "데이터 원본", "서버", "주소", "addr" 및 "네트워크 주소" 키에 해당합니다. 이러한 값 중 제공된 연결 문자열 내에 제공된 값에 관계없이 해당 문자열에서 SqlConnectionStringBuilder 만든 연결 문자열은 잘 알려진 "데이터 원본" 키를 사용합니다.