ServerVersion Property
Collapse the table of content
Expand the table of content

OleDbConnection.ServerVersion Property

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.


Exception Type Condition
InvalidOperationException The connection is closed.


The ServerVersion property maps to the OLE DB DBPROP_DBMSVER property. If ServerVersion is not supported by the underlying OLE DB provider, an empty string is returned.

The version is of 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 provider must render the product version in this form but can also append the product-specific version—for example, "04.01.0000 Rdb 4.1". The string is of 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 OleDbConnection and displays some of its read-only properties.

[Visual Basic] 
Public Sub CreateOleDbConnection()
    Dim myConnectString As String = "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI;"
    Dim myConnection As New OleDbConnection(myConnectString)
    MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _
       + ControlChars.NewLine + "State: " + myConnection.State)
End Sub

public void CreateOleDbConnection() 
    string myConnectString = "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI;";
    OleDbConnection myConnection = new OleDbConnection(myConnectString);
    MessageBox.Show("ServerVersion: " + myConnection.ServerVersion
       + "\nState: " + myConnection.State);

void CreateOleDbConnection() 
    String* myConnectString = S"Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI;";
    OleDbConnection* myConnection = new OleDbConnection(myConnectString);
    MessageBox::Show(String::Format( S"ServerVersion: {0}\nState: {1}", myConnection->ServerVersion, __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

OleDbConnection Class | OleDbConnection Members | System.Data.OleDb Namespace

© 2016 Microsoft