From:
<car...@te...> - 2004-07-10 11:28:34
|
Hello: I want to know opinions about the implementation of the Firebird events system in v1.7. Here is a little usage sample: static void Main(string[] args) { string connectionString = @"Database=localhost/3050:employee;user=sysdba;password=masterkey;Charset=NONE;"; FbConnection connection = new FbConnection(connectionString); connection.Open(); FbEvent revent = new FbEvent(connection); revent.AddEvents(new string[] {"new_order"}); /* Add callback to the Firebird events */ revent.EventCountsCallback = new FbEventCountsCallback(EventCounts); /* queue events */ connection.QueueEvents(revent); string sql = "INSERT INTO SALES (PO_NUMBER, CUST_NO, SALES_REP, ORDER_STATUS, ORDER_DATE, SHIP_DATE, DATE_NEEDED, PAID, QTY_ORDERED, TOTAL_VALUE, DISCOUNT, ITEM_TYPE) VALUES (@po_number, 1004, 11, 'new', '1991-03-04 00:00:00', '1991-03-05 00:00:00', NULL, 'y', 10, 5000, 0.100000001490116, 'hardware');"; FbCommand command = new FbCommand(sql, connection); command.Parameters.Add("@po_number", FbDbType.Char, 8); for (int i = 211; i < 220; i++) { command.Parameters[0].Value = "V91E0" + i.ToString(); command.ExecuteNonQuery(); /* Re-queue for the next event */ connection.QueueEvents(revent); } connection.Close(); } static void EventCounts(FbEvent revent, int[] actualCounts) { if (revent.HasChanges) { for (int i = 0; i < actualCounts.Length; i++) { Console.WriteLine("{0} : {1}", revent[i], actualCounts[i]); } } } The program output is: new_order : 0 new_order : 1 new_order : 2 new_order : 3 new_order : 4 new_order : 5 new_order : 6 new_order : 7 new_order : 8 new_order : 9 Opinions are welcome !! -- Best regards Carlos Guzmán Álvarez Vigo-Spain |