dotConnect for MySQL Documentation
Devart.Data.MySql Namespace / MySqlDump Class / Error Event
Example

In This Topic
    Error Event (MySqlDump)
    In This Topic
    Occurs when a SQL statement within dump script has produced an error.
    Syntax
    'Declaration
     
    Public Event Error As ScriptErrorEventHandler
    public event ScriptErrorEventHandler Error
    Event Data

    The event handler receives an argument of type ScriptErrorEventArgs containing data related to this event. The following ScriptErrorEventArgs properties provide information specific to this event.

    PropertyDescription
    Gets the System.Exception instance that DbScript throws.  
    Gets or sets whether the current error will be ignored or not.  
    Gets length of statement where an error occurred.  
    Gets number of the line where an error occurred.  
    Gets position in the line where an error occurred.  
    Gets offset of statement where an error occurred.  
    Gets type of the statement that caused an error.  
    Gets SQL statement where an error occurred.  
    Remarks
    This event can be generated by the Restore method when an error occurs during script execution. In the event handler you can choose whether to ignore the error and continue or to stop execution. The Devart.Common.ScriptErrorEventArgs object available in event handler provides information about the statement that initiated the error.
    Example
    private static void myDump_Error(object sender, Devart.Common.ScriptErrorEventArgs e)
    {
      Console.WriteLine("Invalid query:");
      Console.WriteLine(e.Text);
      Console.WriteLine("At line: " + e.LineNumber.ToString());
    }
    
    static void Main(string[] args)
    {
      MySqlConnection myConnection = new MySqlConnection();
      myConnection.ConnectionString = "User Id=root;Password=root;Host=localhost;Port=3306;Database=Test;";
      myConnection.Open();
    
      MySqlDump myDump = new MySqlDump();
      myDump.Connection = myConnection;
    
      myDump.Error += new Devart.Common.ScriptErrorEventHandler(myDump_Error);
    
      try
      {
        myDump.Restore("d:\\tmp\\mydump.dmp");
      }
      finally
      {
        myConnection.Close();
      }
    }
    Private Shared Sub myDump_Error(ByVal sender As Object, ByVal e As Devart.Common.ScriptErrorEventArgs)
      Console.WriteLine("Invalid query:")
      Console.WriteLine(e.Text)
      Console.WriteLine(("At line:" & e.LineNumber.ToString))
    End Sub
    
    Shared Sub Main(ByVal args As String())
      Dim myConnection As New MySqlConnection
      myConnection.ConnectionString = "User Id=root;Password=root;Host=localhost;Port=3306;Database=Test;";
      myConnection.Open()
      Dim myDump As New MySqlDump
      myDump.Connection = myConnection
      myDump.ExportAll = True
    
      AddHandler myDump.Error, AddressOf myDump_Error
      Try
        myDump.Restore("d:\\tmp\\mydump.dmp")
      Finally
        myConnection.Close()
      End Try
      RemoveHandler myDump.Error, AddressOf myDump_Error
    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