1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| con = new OracleConnection(constr);
try
{
con.Open();
if (con.State == ConnectionState.Open)
{
OracleCommand cmd = con.CreateCommand();
cmd.CommandText = "Select *FROM DEMO_CUSTOMERS";
OracleDependency.Port = 1005;
dependency = new OracleDependency();
dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
dependency.AddCommandDependency(cmd);
cmd.Notification.IsNotifiedOnce = false;
cmd.AddRowid = true;
cmd.ExecuteNonQuery();
}
}
catch (Exception exp)
{
MessageBox.Show(exp.InnerException.ToString());
throw;
}
void dependency_OnChange(object sender, OracleNotificationEventArgs eventArgs)
{
try
{
MessageBox.Show("Table has been Changed");
MessageBox.Show(eventArgs.Source.ToString());
MessageBox.Show(eventArgs.Info.ToString());
MessageBox.Show(eventArgs.Source.ToString());
MessageBox.Show(eventArgs.Type.ToString());
DataTable dt = eventArgs.Details;
}
catch (Exception exception)
{
MessageBox.Show(exception.InnerException.ToString());
}
} |
Partager