DB2Error Class
Collects information relevant to a warning or error returned by the database.
- Namespace:
IBM.Data.DB2
- Assembly:
IBM.Data.DB2
(inIBM.Data.DB2.dll
)
Inheritance hierarchy
System.Object
IBM.Data.DB2.DB2Error
Syntax
[Visual Basic]
<Serializable>
NotInheritable Public Class DB2Error
[C#]
[Serializable]
public sealed class DB2Error
[C++]
[Serializable]
public __gc __sealed class DB2Error
[JScript]
public
Serializable
class DB2Error
Remarks
An instance of this class is created whenever an error occurs on a database operation in your application. Each instance of DB2Error created by the DB2DataAdapter is then managed by the DB2®ErrorCollection class, which in turn is created by the DB2Exception class.
If the severity of the error is too great, the server can close the DB2Connection. If the server does close the connection, the application will need to open a new connection.
Example
[Visual Basic, C#] The following example displays the properties of the DB2Error.
[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.