OleDbConnection.Database Property

 

Gets the name of the current database or the database to be used after a connection is opened.

Namespace:   System.Data.OleDb
Assembly:  System.Data (in System.Data.dll)

Public Overrides ReadOnly Property Database As String

Property Value

Type: System.String

The name of the current database or the name of the database to be used after a connection is opened. The default value is an empty string.

The Database property updates dynamically. If you change the current database using a SQL statement or the ChangeDatabase method, an informational message is sent and the property is updated automatically.

The following example creates an OleDbConnection and displays some of its read-only properties.

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

.NET Framework
Available since 1.1
Return to top
Show: