I am working on a C# (Visual Studio 2019) Form application and I need to fetch some table data from a Firebird database. For SQL Server, I am doing it successfully with TableDependency but in Firebird I am trying to do something similar to listen any record inserted in a Firebird table. Can anyone you please help? Listener needs to listen always if there is a new record in a table.
Asked
Active
Viewed 243 times
1
-
You will need to define an on insert trigger that posts an event, and then listen for that event to occur. – Mark Rotteveel Apr 02 '20 at 14:58
-
Thank you for your reply. I have inserted trigger and event also. But I am trying to develop a listener for that event. I dont know if BackgroundWorker will do the task for me or i have to generate something to listen. Clueless right now. Any help please ? – Jugnu Khan Apr 02 '20 at 15:23
-
I don't really program in C# anymore, so I can't readily recall, but you need to use `FbRemoteEvent` to listen for events. – Mark Rotteveel Apr 02 '20 at 15:42
1 Answers
0
static void Main(string[] args)
{
try
{
using (var events = new FbRemoteEvent(@"database=localhost:Some.FDB;user=sysdba;password=masterkey"))
{
//events.RemoteEventCounts += (sender, e) => Console.WriteLine($"Event: {e.Name} | Counts: {e.Counts}");
events.RemoteEventCounts += (sender, e) => rinIt(e); ;
events.RemoteEventError += (sender, e) => Console.WriteLine($"ERROR: {e.Error}");
events.QueueEvents("SHOOTSALES");
Console.WriteLine("Listening...");
Console.ReadLine();
}
}
catch (Exception ex)
{
Console.WriteLine("Error...");
Console.ReadLine();
}
void rinIt(FbRemoteEventCountsEventArgs e)
{
Console.WriteLine($"Event: {e.Name} | Counts: {e.Counts}");
}
}

Jugnu Khan
- 63
- 3
- 9
-
Reference: https://github.com/cincuranet/FirebirdSql.Data.FirebirdClient – Jugnu Khan Apr 02 '20 at 17:15