OleDbConnection.ServerVersion 屬性

定義

取得字串,其包含用戶端連接之伺服器的版本。

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

屬性值

連接伺服器的版本。

屬性

例外狀況

連接關閉。

範例

下列範例會建立 , OleDbConnection 並顯示其部分唯讀屬性。

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

        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
    End Using
End Sub

備註

屬性 ServerVersion 會對應至 OLE DB DBPROP_DBMSVER 屬性。 如果 ServerVersion 基礎 OLE DB 提供者不支援 ,則會傳回空字串。

版本的格式為 ##.##.####,其中前兩位數是主要版本、接下來兩位數是次要版本,最後四位數是發行版本。 提供者必須以此形式轉譯產品版本,但也可以附加產品特定版本 ,例如“04.01.0000 Rdb 4.1”。 此字串的格式為 major.minor.build,其中 major 和 minor 正好是兩位數,而組建剛好是四位數。

適用於

另請參閱