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

In This Topic
    ClientVersion Property
    In This Topic
    Gets the version of MySQL Client library (libmysql.dll or libmysqld.dll).
    Syntax
    'Declaration
     
    Public ReadOnly Property ClientVersion As String
    public string ClientVersion {get;}

    Property Value

    The version of MySQL Client library (libmysql.dll or libmysqld.dll).
    Remarks
    Inquiry this property to determine capabilities of the client library. This property is meaningful when Direct property is false (libmysql.dll is used). When Direct is true, the ClientVersion property returns "4.1", though capabilities provided by dotConnect for MySQL are much wider.
    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