当更改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.

谢谢!

有帮助吗?

解决方案

ODP.NET确实实施了ADO.NET 2.0指定的更改通知。

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

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top