Reputation: 1339
just a simple question. Is that any way to trace the database when any table is insert update or delete recently?For example I update 4 user detail in my database. A log file will be create and log that 4 record has been update in user table.
Is it possible to make it?
Upvotes: 0
Views: 1579
Reputation: 28279
You can use the power of SQL Server Auditing https://sqlblog.org/2008/05/06/when-was-my-database-table-last-accessed or you can create trigger to audit your SQL Server database http://weblogs.asp.net/jgalloway/archive/2008/01/27/adding-simple-trigger-based-auditing-to-your-sql-server-database.aspx
Upvotes: 1
Reputation: 7449
I would recommend using Triggers in Database layer and log changes to a table in the database instead of flat file, so that changes will be recorded regardless where changes have be made. Then write something on your UI to display entries from your log table.
Upvotes: 0
Reputation: 63956
You have the answer to your question, right on your tags: use a logging library such as log4net or elmah and log every time an insert/update/delete occurs...
Or implement something on the DB side to insert a record in an audit table every time and insert/update/delete occurs on the table you want. You can use a database trigger, for example.
The bottom line is that you have to write the code/logic to do this.
Upvotes: 0