This documentation is archived and is not being maintained.

OdbcConnection.ServerVersion Property

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Gets a string containing the version of the server to which the client is connected.

[Visual Basic]
Public ReadOnly Property ServerVersion As String
public string ServerVersion {get;}
public: __property String* get_ServerVersion();
public function get ServerVersion() : String;

Property Value

The version of the connected server. The default value is an empty string ("") until the connection is opened.


Exception Type Condition
InvalidOperationException The connection is closed.


If ServerVersion is not supported by the underlying ODBC driver, an empty string ("") is returned.

The ServerVersion property takes the form '##.##.####,' where the first two digits are the major version, the next two digits are the minor version, and the last four digits are the release version. The driver must render the product version in this form but can also append the product-specific version as a string (for example, "04.01.0000 Rdb 4.1"). This string takes the form '' where major and minor are exactly two digits and build is exactly four digits.


[Visual Basic, C#, C++] The following example creates an OdbcConnection and displays the ServerVersion.

[Visual Basic] 
Public Sub CreateOdbcConnection()
    Dim myConnectString As String = "DRIVER={SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=northwind;"
    Dim myConnection As New OdbcConnection(myConnectString)
    MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _
       + ControlChars.NewLine + "State: " + myConnection.State)
End Sub

public void CreateOdbcConnection() 
    string myConnectString = "DRIVER={SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=northwind;";
    OdbcConnection myConnection = new OdbcConnection(myConnectString);
    MessageBox.Show("ServerVersion: " + myConnection.ServerVersion
       + "\nState: " + myConnection.State);

    void CreateOdbcConnection()
        String* myConnectString = S"DRIVER= {SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=northwind;";
        OdbcConnection* myConnection = new OdbcConnection(myConnectString);
        MessageBox::Show(String::Concat(S"ServerVersion: ", myConnection->ServerVersion, S"\nState: ", __box (myConnection->State)));

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

OdbcConnection Class | OdbcConnection Members | System.Data.Odbc Namespace