DB2 Version 9.7 for Linux, UNIX, and Windows

DB2ErrorCollection Class

Collects all generated errors.

Namespace:
IBM.Data.DB2
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Inheritance hierarchy

System.Object
   IBM.Data.DB2.DB2ErrorCollection

Syntax

[Visual Basic]
<Serializable>
NotInheritable Public Class DB2ErrorCollection
   Implements ICollection, IEnumerable
[C#]
[Serializable]
public sealed class DB2ErrorCollection : ICollection, IEnumerable
[C++]
[Serializable]
public __gc __sealed class DB2ErrorCollection : public
   ICollection, IEnumerable
[JScript]
public
   Serializable
class DB2ErrorCollection implements ICollection,
   IEnumerable

Remarks

This class is created by DB2Exception to collect instances of the DB2Error class. DB2ErrorCollection always contains at least one instance of the DB2Error class.

Example

[Visual Basic, C#] The following example displays each DB2Error within the DB2ErrorCollection.

[Visual Basic]
Public Sub DisplayDB2ErrorCollection(myException As DB2Exception)
    Dim i As Integer
    For i = 0 To myException.Errors.Count - 1
        MessageBox.Show("Index #" + i.ToString() + ControlChars.Cr _
           + "Message: " + myException.Errors(i).Message + ControlChars.Cr _
           + "Native: " + myException.Errors(i).NativeError.ToString() 
                        + ControlChars.Cr _
           + "Source: " + myException.Errors(i).Source + ControlChars.Cr _
           + "SQL: " + myException.Errors(i).SQLState + ControlChars.Cr)
    Next i
End Sub

[C#]
public void DisplayDB2ErrorCollection(DB2Exception myException)
{
   for (int i=0; i < myException.Errors.Count; i++)
   {
      MessageBox.Show("Index #" + i + "\n" +
             "Message: " + myException.Errors[i].Message + "\n" +
             "Native: " + myException.Errors[i].NativeError.ToString() + "\n" +
             "Source: " + myException.Errors[i].Source + "\n" +
             "SQL: " + myException.Errors[i].SQLState + "\n");
   }
}

Thread safety

Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

Version information

Last update
This topic was last updated for: IBM DB2 Version 9.5
.NET Framework version
Supported in: 2.0, 3.0, 3.5, and 4.0
IBM Data Server Client
Supported in: 8.1.2 and up