DB2ErrorCollection.Count Property

Gets the number of errors in the collection.

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

Syntax


[Visual Basic]
<Serializable>
Public ReadOnly Property Count As Integer  Implements _
   ICollection.Count
[C#]
[Serializable]
public int Count {get;}
[C++]
[Serializable]
public: __property int get_Count();
[JScript]
public
   Serializable
function get Count() : int;
Implements:
ICollection.Count

Property value

The total number of errors in the collection.

Example

[Visual Basic, C#] The following example displays each DB2®Error 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");
   }
}