当数据库表中的某个字段发生更改时,有没有办法获得通知?我在 .NET 4.0 应用程序上使用 ODP.NET 和 Oracle 11g。
后期编辑:所以,从答案中我了解到这是可能的,所以我尝试了一些东西。这是如何:
OracleConnection con = new OracleConnection(constr);
OracleCommand cmd = new OracleCommand(sql, con);
con.Open();
cmd.AddRowid = true;
**OracleDependency dep = new OracleDependency(cmd);**
cmd.Notification.IsNotifiedOnce = false;
dep.OnChange += new OnChangeEventHandler(OnMyNotification);
OracleDataAdapter da = new OracleDataAdapter();
da.SelectCommand = cmd;
da.Fill(ds, tablename);
ultraGrid1.SetDataBinding(ds, tablename);
问题是它卡在标记的like处,60秒后抛出错误:
The CLR has been unable to transition from COM context 0x25f638 to COM context 0x25f7a8 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
谢谢!