0

I am learning databases with MySQL and C#. I am looking for way to respond to database changes so that users doesn't work with old data. Is the RowChanged event on DataTable object triggered only when the Row object is changed or does it respond to changes to database table.

michael melena
  • 535
  • 5
  • 12
  • 1
    @TaW there is no SqlDependency object for MySQL; see https://stackoverflow.com/a/26395181 and https://stackoverflow.com/a/3768609. – Bradley Grainger Aug 01 '18 at 19:51

1 Answers1

0

The RowChanged event will only be raised for local changes to the Row; it will not be raised if there are changes on the database server. MySQL Server doesn't support the server-side features necessary to make this possible. (The SqlDependency class, which is used for Microsoft SQL Server, is based on the Service Broker infrastructure, which doesn't exist in MySQL.)

To get updates when the database is changed, you'll have to implement some sort of polling based on the shape of the data in your tables (e.g., does it have a TIMESTAMP column or some other value that always changes?); see Update C# client whenever database is updated.

Bradley Grainger
  • 27,458
  • 4
  • 91
  • 108