共用方式為


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 正好是兩位數,build 則是四位數。

適用於

另請參閱