odp.net db更改通知

时间:2011-09-05 11:33:50

标签: .net oracle odp.net change-notification

有没有办法在db表中的某个字段发生变化时收到通知? 我在.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);

问题是它被卡在标记的状态,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.

谢谢!

1 个答案:

答案 0 :(得分:1)

ODP.Net确实实现了ADO.Net 2.0指定的更改通知。

这里有一些简短的描述和一些示例代码的链接:

http://www.oracle.com/technetwork/issue-archive/win06odp-099708.html