Firebird ADO.NET Provider SDK Documentation - v1.7

FbException Class

The exception that is thrown when Firebird Server returns a warning or error. This class cannot be inherited.

For a list of all members of this type, see FbException Members.

System.Object
   System.Exception
      System.SystemException
         FirebirdSql.Data.Firebird.FbException

[Visual Basic]
<Serializable>
NotInheritable Public Class FbException
    Inherits SystemException
[C#]
[Serializable]
public sealed class FbException : SystemException

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

This class is created whenever the Firebird Server .NET Data Provider encounters an error generated from the server. FbException always contains at least one instance of FbError.

Example

public void ThrowFbException() 
{
    string         myConnString = "Database=C:\\PROGRAM FILES\\FIREBIRD\\EXAMPLES\\EMPLOYEE.GDB;User=SYSDBA;Password=masterkey;Dialect=3;Server=localhost";    
    FbConnection myConnection  = new FbConnection(myConnString);
    
    try 
    {
    myConnection.Open();
    }
    catch (FbException e) 
    {
    FbErrorCollection myErrors = e.Errors;
        
    Console.WriteLine("Class: {1}", e.Class);
    Console.WriteLine("Error #{1}: {2} on line {3}.", e.Number, e.Message, e.LineNumber);
    Console.WriteLine("Error reported by {1} while connected to {2}", e.Source, e.Server);
    Console.WriteLine("Neither record was written to database.");
    Console.WriteLine("Errors collection contains:");

    for (int i=0; i < myErrors.Errors.Count; i++) 
    {
        Console.WriteLine("Class: {1}", myErrors[i].Class);
        Console.WriteLine("Error #{1}: {2} on line {3}.", myErrors[i].Number, myErrors[i].Message, myErrors[i].LineNumber);
        Console.WriteLine("Error reported by {1} while connected to {2}", myErrors[i].Source, myErrors[i].Server);
    }
    }
}
                

Requirements

Namespace: FirebirdSql.Data.Firebird

Assembly: FirebirdSql.Data.Firebird (in FirebirdSql.Data.Firebird.dll)

See Also

FbException Members | FirebirdSql.Data.Firebird Namespace