dotConnect for Oracle Documentation
Devart.Data.Oracle Namespace / OracleLoader Class / Error Event
Example

Error Event (OracleLoader)
Raises when an error occurs during a load operation.
Syntax
'Declaration
 
Public Event Error As OracleLoaderErrorEventHandler
 
Event Data

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

PropertyDescription
Gets column number where an error occurred.  
Gets the OracleException instance that an OracleLoader throws.  
Gets or sets whether the current error will be ignored or not.  
Gets row number where an error occurred.  
Remarks
The event handler receives an argument of OracleLoaderErrorEventArgs type containing data related to this event. The following OracleLoaderErrorEventArgs properties provide information specific to this event:
Property Description
OracleLoaderErrorEventArgs.Column Gets column where an error occurred.
OracleLoaderErrorEventArgs.Row Gets row where an error occurred.
OracleLoaderErrorEventArgs.Exception Gets OracleException object with error specific information.
OracleLoaderErrorEventArgs.Ignore Specifies whether current error will be ignored.

Clients that want to process errors raised by the server should create an OracleLoaderErrorEventHandler delegate to listen to this event.

Example

The following sample demonstrates using the Error event. Perform the following script against the database before executing the code:

CREATE TABLE DEPT(
  DEPTNO INTEGER PRIMARY KEY,
  DNAME VARCHAR(14),
  LOC VARCHAR(13)
);

INSERT INTO DEPT VALUES (10,'ACCOUNTING','NEW YORK');
INSERT INTO DEPT VALUES (20,'RESEARCH','DALLAS');
INSERT INTO DEPT VALUES (30,'SALES','CHICAGO');
INSERT INTO DEPT VALUES (40,'OPERATIONS','BOSTON');
static void Main(string[] args)
{
        OracleConnection connection = new OracleConnection("your connection string");
        connection.Open();
        connection.AutoCommit = true;

        OracleLoader loader = new OracleLoader();
        loader.Connection = connection;
        loader.Error += new OracleLoaderErrorEventHandler(loader_Error);
        loader.TableName = "dept";
        loader.CreateColumns();
        loader.Open();

        loader.SetValue("deptno", 10);
        loader.SetValue("dname", "test");
        loader.SetValue("loc", "test");
        loader.NextRow();

        loader.SetValue("deptno", 20);
        loader.SetValue("dname", "test");
        loader.SetValue("loc", "test");
        loader.NextRow();

        loader.SetValue("deptno", 92);
        loader.SetValue("dname", "test");
        loader.SetValue("loc", "test");
        loader.NextRow();
        loader.Close();
}

static void loader_Error(object sender, OracleLoaderErrorEventArgs e)
{
        if (e.Exception.Errors == null)
                Console.WriteLine(e.Exception.Message);
        else
        {
                foreach (OracleError error in e.Exception.Errors)
                        Console.WriteLine(error.Message);
        }
        e.Ignore = true;
}
Sub Main()
        Dim connection As New OracleConnection("your connection string")
        connection.Open()
        connection.AutoCommit = True

        Dim loader As New OracleLoader()
        loader.Connection = connection
        AddHandler loader.Error, New OracleLoaderErrorEventHandler(AddressOf loader_Error)
        loader.TableName = "dept" 
        loader.CreateColumns()
        loader.Open()

        loader.SetValue("deptno", 10)
        loader.SetValue("dname", "test")
        loader.SetValue("loc", "test")
        loader.NextRow()

        loader.SetValue("deptno", 20)
        loader.SetValue("dname", "test")
        loader.SetValue("loc", "test")
        loader.NextRow()

        loader.SetValue("deptno", 92)
        loader.SetValue("dname", "test")
        loader.SetValue("loc", "test")
        loader.NextRow()
        loader.Close()
End Sub

Sub loader_Error(sender As Object, e As OracleLoaderErrorEventArgs)
        If e.Exception.Errors Is Nothing Then
                Console.WriteLine(e.Exception.Message)
        Else
                For Each err As OracleError In e.Exception.Errors
                        Console.WriteLine(err.Message)
                Next
        End If
        e.Ignore = True
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