Firebird Events usage in C#

Posted on 2005-04-07
Medium Priority
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 http://firebird.sourceforge.net/index.php?op=devel&sub=netprovider&id=examples#3 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
  • 2
LVL 10

Accepted Solution

kacor earned 1000 total points
ID: 13725411
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):
      FOR Orders
      POST_EVENT ’New order’;

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

ID: 13725577
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

ID: 13751943
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

by:Nick Upson
Nick Upson earned 1000 total points
ID: 13751979
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

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How much do you know about the future of data centers? If you're like 50% of organizations, then it's probably not enough. Read on to get up to speed on this emerging field.
Microsoft Jet database engine errors can crop up out of nowhere to disrupt the working of the Exchange server. Decoding why a particular error occurs goes a long way in determining the right solution for it.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

593 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