Oracledependency event does not fire

I have some problems using OracleDependency.

I read the msdn and oracle docs and copy the code to try it out.

However, this does not work; the on_my_event event does not fire when the insert is completed.

Does anyone know why?

My user has CHANGE NOTIFICATION privileges in the database. Oracle Server - 11.2.0.3.0.

Here is the code:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Oracle.DataAccess.Client; namespace WindowsFormsApplication1 { public partial class Form1 : Form { string connection_string = "Data Source=My_srv;User Id=My_usr;Password=My_pwd;"; OracleConnection connection = null; OracleDependency dependency = null; OracleCommand my_select = null; OracleCommand my_insert = null; public Form1() { InitializeComponent(); } private void TB_insert_event(object sender, EventArgs e) { if (TB_insert.Text == "Name of your insert") TB_insert.Clear(); } private void insert(object sender, EventArgs e) { connection = new OracleConnection(connection_string); my_insert = connection.CreateCommand(); my_insert.CommandText = "INSERT INTO USR_DEV_TRUNK.WPARAM (wpa_codeparam) VALUES ('" + TB_insert.Text + "')"; connection.Open(); my_insert.ExecuteNonQuery(); connection.Close(); } private void Set_dep(object sender, EventArgs e) { OracleDependency.Port = 3048; connection = new OracleConnection(connection_string); connection.Open(); my_select = connection.CreateCommand(); my_select.CommandText = "SELECT wpa_codeparam FROM USR_DEV_TRUNK.WPARAM"; dependency = new OracleDependency(); dependency.AddCommandDependency(my_select); my_select.Notification.IsNotifiedOnce = false; my_select.ExecuteNonQuery(); dependency.OnChange += new OnChangeEventHandler(on_my_event); TB_dependency.Text = "The dependency is set, do your insert to see if it works"; connection.Close(); } public void on_my_event(object obj, OracleNotificationEventArgs arg) { TB_dependency.Text = "Yay ! It worked !"; } } } 

I have two buttons:

One to set my dependency (function (click): Set_dep)

One for my insert (function (click): insert)

And I have two text fields:

One to get my insert (name: TB_insert)

One to show dependency status (name: TB_dependency)

+4
source share
1 answer

Are you sure that packets on port 3048 are not blocked by a firewall?

Also, once your dependency has been installed, can you see it by requesting the USER_CHANGE_NOTIFICATION_REGS / DBA_CHANGE_NOTIFICATION_REGS views?

0
source

All Articles