odp.net db change notification

二次信任 提交于 2019-12-13 18:14:52

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/7307443/odp-net-db-change-notification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!