Firebird Events usage in C#

Posted on 2005-04-07
Last Modified: 2013-12-09

I am new to firebird. Though I have been reading The Firebird Book and have used Firebird in studying. My question is how to create events in Firebird ( when a row is added in a table via Stored Procedure and how to register and get notified of the said event from a C# application. All this using the .Net Firebird Provider v 1.7.

The example in the book is theoretical and general. The example in this link is thorough but lacks helpful comments, and seems to refer to subscribing to an event on a table with an existing event created.

The example should make use of the FireBird sample database Employee.fdb so I can easily test and apply it


Question by:xms_dev
    LVL 10

    Accepted Solution

    Hi PinoyBug,

    I used only InterBase and Delphi so I can help in the followings to your question:

          ".. seems to refer to subscribing to an event on a table with an existing event created"

    In InterBase you have to create first a trigger. InterBase has the command POST_EVENT and this informs the event handler when the event occurs (the SET TERM is needed for compatibility only):
    SET TERM ^;
          FOR Orders
          POST_EVENT ’New order’;
    SET TERM ;^

    Between the IBExpress components of Delphi there is the IBEvents component. First you register the IBEvents:
    procedure TForm1.FormCreate(Sender: TObject);
         IBDatabase1.Connected := True;
         IBTransaction1.Active := True;
         IBEvents1.Registered := True;

    procedure TForm1.FormDestroy(Sender: TObject);
         IBEvents1.Registered := False;
         IBDatabase1.Connected := False;

    In the Events property of the IBEvents component you write in the "new order" event. The IBEvents component has the event "OnEventAlert". To handle this event alerter you can use the following procedure for example:

    procedure TForm1.IBEvents1EventAlert(Sender: TObject; EventName: String;
    EventCount: Integer; var CancelAlerts: Boolean);
         MessageDlg('Delphi message: ' + EventName + ' event has occured.',
         mtInformation, mbOKCancel, 0);

    To stop the alerts you can use the CancelEvents, or restart alerting by QueueEvents method.

    If a new order will be inserted you'll get the ’New order’ message.

    I hope this helps

    wbr kacor


    Author Comment

    Thanks wbr kacor. Your answer gave me an idea on implementing events based on triggers. But I am looking for implementation of events via Stored Procedure and subscription and consumption by a C# application using the FireBird .Net Provider v 1.7.

    Cheers :)
    LVL 10

    Expert Comment

    For event handling in IB/FB you have to use triggers undependent whether you use C# or other developping environment. As I know this is the only possibilty for this purpose. And the simplest way  you can realise this is the database side I mean. All other solution will be more complicated and not so reliable because the trigger uses the IB/FB's internal mechanism.

    with best regards

    LVL 19

    Assisted Solution

    A trigger could call a stored procedure which in turn raises the event, the application has to register interest in the event (subscription) and then consume them as they occur.

    Please consider trying to describe what you wish to achieve rather than focusing on the method, we may be able to suggest something better suited.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
    SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now