odp.net DB更改通知 [英] odp.net db change notification

查看:262
本文介绍了odp.net DB更改通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法得到一个通知,当某一个领域中的一个数据库表发生变化? 我使用的ODP.NET和Oracle 11g,在.NET 4.0应用程序。

Is there a way to get a notification when a certain field in a db table is changed ? I'm using ODP.NET and Oracle 11g, on a .NET 4.0 app.

在以后编辑: 因此,从问题的答案我明白,这将是可能的,所以我尝试过的东西。 这就是:

LATER EDIT : So, from the answers i understand that it would be possible, so i've tried something. This is how :

        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 problem is that it gets stuck at the marked like and after 60 seconds it throws an error :

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。

ODP.Net does implement the Change notification that is specified by ADO.Net 2.0.

有一个简短的描述和一个链接到一些示例code在这里:

There's a brief description and a link to some sample code here:

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

这篇关于odp.net DB更改通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆