OleDbConnection.DataSource 속성

정의

데이터 소스의 파일 이름 또는 서버 이름을 가져옵니다.

public:
 virtual property System::String ^ DataSource { System::String ^ get(); };
public:
 property System::String ^ DataSource { System::String ^ get(); };
[System.ComponentModel.Browsable(true)]
public override string DataSource { get; }
[System.Data.DataSysDescription("OleDbConnection_DataSource")]
public string DataSource { get; }
[<System.ComponentModel.Browsable(true)>]
member this.DataSource : string
[<System.Data.DataSysDescription("OleDbConnection_DataSource")>]
member this.DataSource : string
Public Overrides ReadOnly Property DataSource As String
Public ReadOnly Property DataSource As String

속성 값

데이터 소스의 파일 이름 또는 서버 이름입니다. 기본값은 빈 문자열입니다.

특성

예제

다음 예제에서는 을 OleDbConnection 만들고 일부 읽기 전용 속성을 표시합니다.

static void OpenConnection(string connectionString)
{
    using (OleDbConnection connection = new OleDbConnection(connectionString))
    {
        try
        {
            connection.Open();
            Console.WriteLine("ServerVersion: {0} \nDataSource: {1}",
                connection.ServerVersion, connection.DataSource);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        // The connection is automatically closed when the
        // code exits the using block.
    }
}
Public Sub OpenConnection(ByVal connectionString As String)

    Using connection As New OleDbConnection(connectionString)
        Try
            connection.Open()
            Console.WriteLine("Server Version: {0} DataSource: {1}", _
                connection.ServerVersion, connection.DataSource)
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
        ' The connection is automatically closed when the
        ' code exits the Using block.
    End Using
End Sub

설명

데이터베이스에 대한 연결이 닫힌 DataSource 경우 속성은 데이터 원본 키워드(keyword) 대해 포함된 ConnectionString 모든 항목을 반환합니다. 연결이 열려 있고 ConnectionString 데이터 원본 키워드(keyword) 값이 "|datadirectory|"로 시작하는 경우 속성은 데이터 원본에 포함된 ConnectionString 모든 항목만 키워드(keyword) 반환합니다. 데이터베이스에 대한 연결이 열려 있는 경우 속성은 네이티브 공급자가 에 대해 DBPROP_INIT_DATASOURCE, 반환하는 항목을 반환하고 비어 있으면 네이티브 공급자가 DBPROP_DATASOURCENAME 반환됩니다.

적용 대상

추가 정보