开发者

odp.net db change notification

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);

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.

Thank you!


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

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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜