OleDbConnection.ServerVersion 屬性

定義

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

C#
public override string ServerVersion { get; }
C#
[System.ComponentModel.Browsable(false)]
[System.Data.DataSysDescription("OleDbConnection_ServerVersion")]
public string ServerVersion { get; }

屬性值

連接伺服器的版本。

屬性

例外狀況

連接關閉。

範例

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

C#
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.
    }
}

備註

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

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

適用於

產品 版本
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

另請參閱