Domanda

C'è un modo per ottenere una notifica quando un determinato campo in una tabella db è cambiato? Sto usando ODP.NET e Oracle 11g, su un'applicazione .NET 4.0.

modificare in seguito: Così, dalle risposte ho capito che sarebbe stato possibile, così ho provato qualcosa. Questo è il modo:

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

Il problema è che si blocca al marcato come e dopo 60 secondi si genera un errore:

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.

Grazie!

È stato utile?

Soluzione

ODP.Net fa implementare la notifica di modifica che viene specificato da ADO.Net 2.0.

C'è una breve descrizione e un link ad alcuni esempi di codice qui:

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top