Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MMNET & Audit Trail
Message
From
02/06/2011 09:50:26
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
02/06/2011 09:06:31
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
ASP.NET
Database:
MS SQL Server
Miscellaneous
Thread ID:
01512531
Message ID:
01512546
Views:
45
>Hi Using MM.NET 3.6 with C#, ASP.NET and SQL Server 2008 R2.
>
>I need to track all changes made to the database. There is no budget for a third party tool so I am looking for something free that will give me the ability to track changes made to all or selected tables, knowing who made the change (using the ID of the currently logged in MM.NET user). I will then need to run queries/reports against this data to answer questions like, "Who made this change when?".
>
>I've found a few articles on SQLServerCentral.com and am reading through them now (for example: http://www.sqlservercentral.com/articles/SQL+Puzzles/anaudittrailgenerator/2067/ but I'm not sure how to adjust that to store the MM.NET user id) and will do some more Googling, but was wondering if anyone here could recommend a solution.

You can add some code in the ABusiness object that is generic to log the changes. It is tricky for a couple of reasons. First the different data types can be challenging especially if you are storing any images or other complex things. Also, the hook methods in MM are many. The post save events do not provide back the values before the save so you have to capture this in the PreSave hook methods and then confirm the logging after the postSave hook method fires. You would be best served by creating your audit tables and create business objects for them. Then add your code in ABusiness object to use those business objects just for saving the data in the audit logs. Put the audit logic in ABusiness object.

The other issue is the different hook methods for different saves, updates, deletes; and depending on if you are using Entity Framework, or if it involves a single entity or an entity list. When I did this, I created my methods to perform the logging and then used all the hook methods to call my auditing but also needed a couple of overloaded methods because the hook methods provide the pre saved data differently. Entity versus datasets, etc.

Tricky, but it can be done without a tremendous amount of code.
Timothy
Timothy Bryan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform