Capturing User Info on updates to an audit table
I've used your book as the basis of my website, and the book was very helpful in all aspects of my development, but I'm stuck trying to add some auditing features to my site. I've created a simple table that contains a character field and an integer field, and on that table I've created a simple trigger that fires on any updates to an audit table that i want to hold both the old and new values of the integer, along with the system time and the user that did the actual update. While I'm capturing both the old and the new values, along with the system time, I'm lost as to how I would capture the user that did the update. My site uses the standard asp.net login controls, so I can capture the user in the code behind, and the update is being done via a standard gridview. My trigger can use SUSER_SNAME(), but that is capturing the actual pc name and not the user name. I'm unsure if i can capture this info in the sql trigger. I was thinking maybe i somehow try to join with the asp.net security db or try using the profile.user.name or something along that line. Any thoughts on how i would go about it?
Thx Again
Last edited by smjg; December 13th, 2012 at 01:41 AM..
Reason: adding more detail
|