How to detect when rows are added to MySQL database?
I have a C # application that grabs files from ftp server, outputs text from file and inserts it into mysql database. From there it takes the data and ftp to another server in our organization.
What I want to do is create a monitoring program that the user can download on their PC with a grid and is updated every time a new entry is added to the mysql database.
What's the best way to do this? I was going to put a timer on the form and check it every 30 seconds or so, but is there a way to do this in real time so that my application knows exactly when an item is added to the database? A control view like FileSystemWatcher, but for a database table?
source to share
There are no generic tools to do this. SQL Server has a concept SQLDependency
, but it is quite an expensive tool to use.
The easiest and easiest way is to do as you thought with a refreshable timer.
If you cannot use any message queuing technology such as MSMQ and send a message yourself indicating that an item has been added. Depending on the size of your project and how important it is that either notification changes are instantaneous or requests are particularly long or expensive, it may be worth it or not.
source to share