OleDbConnection.Database 속성

정의

현재 데이터베이스 이름이나 연결이 열린 후 사용할 데이터베이스의 이름을 가져옵니다.

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

속성 값

현재 데이터베이스 이름이나 연결이 열린 후 사용할 데이터베이스의 이름입니다. 기본값은 빈 문자열입니다.

구현

특성

예제

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

static void OpenConnection(string connectionString)
{
   using (OleDbConnection connection = new OleDbConnection(connectionString))
   {
      try
      {
         connection.Open();
         Console.WriteLine("ServerVersion: {0} \nDatabase: {1}",
             connection.ServerVersion, connection.Database);
      }
      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} Database: {1}", _
             connection.ServerVersion, connection.Database)
      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

설명

속성이 Database 동적으로 업데이트됩니다. SQL 문 또는 메서드를 사용하여 현재 데이터베이스를 ChangeDatabase 변경하는 경우 정보 메시지가 전송되고 속성이 자동으로 업데이트됩니다.

적용 대상

추가 정보