// Open a connection and configure a command inserting rows to the Dept table. OracleConnection conn = new OracleConnection("User Id=Scott;Password=tiger;Data Source=Ora1110"); conn.Open(); OracleCommand cmd = new OracleCommand("INSERT INTO dept VALUES(:deptno_p, :dname_p, :loc_p)", conn); cmd.Parameters.Add("deptno_p", OracleDbType.Integer); cmd.Parameters.Add("dname_p", OracleDbType.VarChar); cmd.Parameters.Add("loc_p", OracleDbType.VarChar); // Populate the parameter collection with arrays. // Notice that the deptno_p parameter array consists of identical numbers. cmd.Parameters["deptno_p"].Value = new int[] { 10, 10, 10, 10 }; cmd.Parameters["dname_p"].Value = new string[] { "ACCOUNTING", "RESEARCH", "SALES", "OPERATIONS" }; cmd.Parameters["loc_p"].Value = new string[] { "NEW YORK", "DALLAS", "CHICAGO", "BOSTON" }; try { cmd.ExecuteArray(4); } // An exception will be thrown as the unique constraint is violated. catch (OracleException ex) { OracleErrorCollection errorCollection = ex.Errors; foreach (Devart.Data.Oracle.OracleError error in errorCollection) { // Ignore the first non-informative exception ('errors in DML array') if (error.Code != 24381) Console.WriteLine(error.Message); } } Console.Read();
' Open a connection and configure a command inserting rows to the Dept table. Dim conn = New OracleConnection("User Id=Scott;Password=tiger;Data Source=Ora1110") conn.Open() Dim cmd = New OracleCommand("INSERT INTO dept VALUES(:deptno_p, :dname_p, :loc_p)", conn) cmd.Parameters.Add("deptno_p", OracleDbType.Integer) cmd.Parameters.Add("dname_p", OracleDbType.VarChar) cmd.Parameters.Add("loc_p", OracleDbType.VarChar) ' Populate the parameter collection with arrays. ' Notice that the deptno_p parameter array consists of identical numbers. cmd.Parameters("deptno_p").Value = New Integer() {10, 10, 10, 10} cmd.Parameters("dname_p").Value = New String() {"ACCOUNTING", "RESEARCH", "SALES", "OPERATIONS"} cmd.Parameters("loc_p").Value = New String() {"NEW YORK", "DALLAS", "CHICAGO", "BOSTON"} Try cmd.ExecuteArray(4) ' An exception will be thrown as the unique constraint is violated. Catch ex As OracleException Dim ErrorCollection As OracleErrorCollection = ex.Errors For Each OraError As Devart.Data.Oracle.OracleError In ErrorCollection ' Ignore the first non-informative exception ('errors in DML array') If OraError.Code <> 24381 Then _ Console.WriteLine(OraError.Message) Next End Try Console.Read()
System.Object
Devart.Data.Oracle.OracleError