Bewerken

Delen via


OdbcError Class

Definition

Collects information relevant to a warning or error returned by the data source.

public ref class OdbcError sealed
public sealed class OdbcError
[System.Serializable]
public sealed class OdbcError
type OdbcError = class
[<System.Serializable>]
type OdbcError = class
Public NotInheritable Class OdbcError
Inheritance
OdbcError
Attributes

Examples

The following example displays the properties of the OdbcError class.

public void DisplayOdbcErrorCollection(OdbcException exception)
{
    for (int i = 0; i < exception.Errors.Count; i++)
    {
        Console.WriteLine("Index #" + i + "\n" +
            "Message: " + exception.Errors[i].Message + "\n" +
            "Native: " + exception.Errors[i].NativeError.ToString() + "\n" +
            "Source: " + exception.Errors[i].Source + "\n" +
            "SQL: " + exception.Errors[i].SQLState + "\n");
    }
    Console.ReadLine();
}
Public Sub DisplayOdbcErrorCollection(ByVal exception As OdbcException)
    Dim i As Integer

    For i = 0 To exception.Errors.Count - 1
        Console.WriteLine("Index #" & i.ToString() & ControlChars.Cr _
           & "Message: " & exception.Errors(i).Message & ControlChars.Cr _
           & "Native: " & exception.Errors(i).NativeError.ToString() & ControlChars.Cr _
           & "Source: " & exception.Errors(i).Source & ControlChars.Cr _
           & "SQL: " & exception.Errors(i).SQLState & ControlChars.Cr)
    Next i
    Console.ReadLine()
End Sub

Remarks

This class is created by the OdbcDataAdapter whenever an error occurs. Each instance of OdbcError created by the OdbcDataAdapter is then managed by the OdbcErrorCollection class, which in turn is created by the OdbcException class.

If the severity of the error is too great, the server may close the OdbcConnection. However, the user can reopen the connection and continue.

Properties

Message

Gets a short description of the error.

NativeError

Gets the data source-specific error information.

Source

Gets the name of the driver that generated the error.

SQLState

Gets the five-character error code that follows the ANSI SQL standard for the database.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Gets the complete text of the error message.

Applies to

See also