dotConnect for MySQL Documentation
Devart.Data.MySql Namespace / MySqlConnection Class / ServerVersion Property
Example

ServerVersion Property (MySqlConnection)
Gets a string containing the version of the instance of MySQL to which the client is connected.
Syntax
'Declaration
 
Public Shadows ReadOnly Property ServerVersion As String
 

Property Value

The version of the instance of MySQL.
Remarks
The version is formatted like "4.0.15".
Example
In the following example client and server versions are analysed, and, if both support Devart.Common.DbCommand.Prepare() method, the process of preparing the query is initiated; otherwise the query is run unprepared.
public void GetMyData(string myConnectionString)
{
  MySqlConnection myConn = new MySqlConnection(myConnectionString);
  string mySelectQuery = "SELECT * FROM Test.Dept";
  MySqlCommand myCommand = new MySqlCommand(mySelectQuery);
  myCommand.Connection = myConn;
  myConn.Open();
  if (string.Compare(myConn.ClientVersion,"4.1")>=0
    & string.Compare(myConn.ServerVersion,"4.1")>=0)
  {
    myCommand.Prepare();
  }
  try
  {
    MySqlDataReader myReader = myCommand.ExecuteReader();
    ...
    myReader.Close();
  }
  finally
  {
    myConn.Close();
  }
}
Public Sub GetMyData(ByVal myConnectionString As String)
  Dim myConn As MySqlConnection = New MySqlConnection(myConnectionString)
  Dim mySelectQuery As String = "SELECT * FROM Test.Dept"
  Dim myCommand As MySqlCommand = New MySqlCommand(mySelectQuery)
  myCommand.Connection = myConn
  myConn.Open()
  Dim Client_OK As Boolean = String.Compare(myConn.ClientVersion, "4.1") >= 0
  Dim Server_OK As Boolean = String.Compare(myConn.ServerVersion, "4.1") >= 0
  If Client_OK And Server_OK Then
    myCommand.Prepare()
  End If
  Try
    Dim myReader As MySqlDataReader = myCommand.ExecuteReader()
    ...
    myReader.Close()
  Finally
    myConn.Close()
  End Try
End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also