ServerVersion Property

MySQL Connector.Net

Collapse image Expand Image Copy image CopyHover image
Gets a string containing the version of the MySQL server to which the client is connected.

Namespace: MySql.Data.MySqlClient
Assembly: MySql.Data (in MySql.Data.dll) Version: 6.8.4.0

Syntax

C#
public override string ServerVersion { get; }
Visual Basic
Public Overrides ReadOnly Property ServerVersion As String
	Get
Visual C++
public:
virtual property String^ ServerVersion {
	String^ get () override;
}

Return Value

The version of the instance of MySQL.

Examples

The following example creates a MySqlConnection, opens it, displays some of its properties, then closes the connection.
Visual Basic Copy imageCopy
Public Sub CreateMySqlConnection(myConnString As String)
Dim myConnection As New MySqlConnection(myConnString)
myConnection.Open()
MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _
+ ControlChars.Cr + "State: " + myConnection.State.ToString())
myConnection.Close()
End Sub
C# Copy imageCopy
public void CreateMySqlConnection(string myConnString)
{
MySqlConnection myConnection = new MySqlConnection(myConnString);
myConnection.Open();
MessageBox.Show("ServerVersion: " + myConnection.ServerVersion +
"\nState: " + myConnection.State.ToString());
myConnection.Close();
}

Exceptions

Exception Condition
System..::..InvalidOperationException The connection is closed.

See Also