LadislavM LadislavM - 1 year ago 272
C# Question

Change Notification with Oracle Dependency in C#

I'm trying to get oracle database change notification in c#. I found
this tutorial about how to get these notifications. I've also created simple win form application for catching notifications

public partial class Form1 : Form
public Form1()

private void SetUpNotification()

OracleConnection conn = null;
OracleDependency dep = null;

conn = new OracleConnection(login);

var cmd = new OracleCommand("select * from customer_details", conn);


cmd.AddRowid = true;
dep = new OracleDependency(cmd);
cmd.Notification.IsNotifiedOnce = false;

dep.OnChange += new OnChangeEventHandler(dep_OnChange);
catch(Exception e)
MessageBox.Show(e.Message, e.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);

void dep_OnChange(object sender, OracleNotificationEventArgs eventArgs)
MessageBox.Show(eventArgs.Details.ToString(), "Database changed");

Login string and OracleCommand cmd are 100% fine. I tried also to change database programmatically, it changed data in database, but didn't fired OnChange event.

I also granted notifications tu USR user

grant change notification to USR

and job_queue_processes are greater than zero.

Can be a problem in a fact, that I am using Express edition of oracle database?

Answer Source

I found out the solution. Problem wasn't in edition of Oracle database, but in the version. Version of Oracle server was and version of client was and this little difference was causing the problem.

So for the future, alway check the versions of client and server, when encountering similar problem.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download