다음을 통해 공유


SqlConnection.ServerVersion 속성

정의

클라이언트가 연결된 SQL Server 인스턴스의 버전을 포함하는 문자열을 가져옵니다.

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("SqlConnection_ServerVersion")]
public string ServerVersion { get; }
[System.ComponentModel.Browsable(false)]
public override string ServerVersion { get; }
member this.ServerVersion : string
[<System.ComponentModel.Browsable(false)>]
[<System.Data.DataSysDescription("SqlConnection_ServerVersion")>]
member this.ServerVersion : string
[<System.ComponentModel.Browsable(false)>]
member this.ServerVersion : string
Public Overrides ReadOnly Property ServerVersion As String
Public ReadOnly Property ServerVersion As String

속성 값

SQL Server 인스턴스의 버전입니다.

특성

예외

연결이 닫혔습니다.

ServerVersion 는 반환된 작업이 완료되지 않았고 호출 후 연결이 열리지 않은 동안 호출 OpenAsync(CancellationToken)되었습니다.

예제

다음 예제에서는 속성을 SqlConnection 만들고 표시합니다 ServerVersion .

private static void CreateSqlConnection(string connectionString)
{
    using (SqlConnection connection = new SqlConnection(connectionString))
    {
        connection.Open();
        Console.WriteLine("ServerVersion: {0}", connection.ServerVersion);
        Console.WriteLine("State: {0}", connection.State );
    }
}
 Private Sub CreateSqlConnection(ByVal connectionString As String)
     Using connection As New SqlConnection(connectionString)
         connection.Open()
         Console.WriteLine("ServerVersion: {0}", connection.ServerVersion)
         Console.WriteLine("State: {0}", connection.State)
     End Using
End Sub

설명

버전은 ##.##.# 형식입니다. 여기서 처음 두 자리는 주 버전이고, 다음 두 자리는 부 버전이고, 마지막 네 자리는 릴리스 버전입니다. 문자열은 major.minor.build 형식입니다. 여기서 주 및 부는 정확히 두 자리이고 빌드는 정확히 4자리입니다.

ServerVersion 는 반환된 작업이 완료되지 않았고 호출 후 연결이 열리지 않은 동안 호출 OpenAsync되었습니다.

적용 대상

추가 정보