dotConnect for MySQL Documentation
Devart.Data.MySql Namespace / MySqlException Class
Members Example

In This Topic
    MySqlException Class
    In This Topic
    The exception that is generated when MySQL returns an error.
    Syntax
    Remarks
    This class is created whenever dotConnect for MySQL encounters an error generated by the server, or MySqlConnection has been closed before attempting to execute an operation on the server.
    Example
    The following example generates a MySqlException due to a non-existing table, and then displays the exception.
    public void ThrowMySqlException()
    {
      string mySelectQuery = "SELECT * FROM NONEXISTINGTABLE";
      MySqlConnection myConnection =
        new MySqlConnection(
            "User Id=root;Host=localhost;Database=Test;");
      MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection);
      try
      {
        myCommand.Connection.Open();
      }
      catch (MySqlException myException)
      {
        MessageBox.Show("Message: " + myException.Message + "\n");
      }
    }
    Public Sub ThrowMySqlException()
      Dim mySelectQuery As String = "SELECT * FROM NONEXISTINGTABLE"
      Dim myConnection As New MySqlConnection( _
        "User Id=root;Host=localhost;Database=Test;")
      Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)
      Try
        myCommand.Connection.Open()
      Catch myException As MySqlException
        MessageBox.Show("Message: " + myException.Message + ControlChars.Cr)
      End Try
    End Sub
    Inheritance Hierarchy

    System.Object
       System.Exception
          System.SystemException
             System.Runtime.InteropServices.ExternalException
                System.Data.Common.DbException
                   Devart.Data.MySql.MySqlException

    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