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 変更すると、情報メッセージが送信され、プロパティが自動的に更新されます。

適用対象

こちらもご覧ください