Click here to Skip to main content
15,888,121 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Monitoring mysql database and table updates using C# polling method

I need to monitor MySql database and log the delete, update, etc. operations done or not?

I have many tables in my Myhr database, but want to create a console application, which monitor Myhr db and check if there is any update or deletion is done. If yes, then it must return that value(the operation done).

Code samples will be of great use.
Posted

This is not really a question, it more a list of requirements and you asking for some code so save you trying to do it. I suggest that you read the FAQ on how to ask questions on this forum as it will guide you towards asking questions that you are more likely to get solutions to.

As for your problem, what about using Triggers on the database.
Mysql Triggers[^]

You could set up a trigger on every table in your database to update a log table with any changes. Personally I think it is over kill to have to monitor EVERY table.

But without knowing your database design it is not easy to advise. I also cannot see a reason for needing this sort of monitoring?

An alternative to the triggers, is that each time your application saves data, it writes an entry to the log table and you just poll the log table on a regular basis to see if there are new entries. Again, this removes the need to monitor every table but just monitor 1.
 
Share this answer
 
Comments
Mycroft Holmes 5-Dec-13 3:54am    
Ah so MySQL does support triggers, I'd assumed so.
This sounds like a disaster in the making, the first question that come to mind is WHY.

If MySQL supports triggers then insert the changes into a log table and query the log table.

We use this to keep and audit of changes but I would never consider polling the table. We allow the user to query the log table based on a bunch of criteria.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900