Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi friends,

on my webpage i have gridview to insert,delete, update records

am inserting, updating, deleting records from gridview. using C# ASp.net Sqlserver 2005.

my requirement is i want to save the time stamp after updating the record..so we can know when this record was edited/updated.

Please can you help me, thanks in advance.
Posted
Comments
surendersinghprajapati 26-May-13 5:42am    
How are you saving your data, using EF or something?
Ubaid ur Rahman IT 26-May-13 5:43am    
what is meant by EF ?

For insert and update there is a simple method: add a timestamp filed, and a trigger to update it. And you don't need to (should not) interfere with it from code. But this is rarely enough.
If you really need that for deletion too, you have do implement audit log functionality. Here is a good solution: http://www.sqlservercentral.com/Forums/Topic1307316-392-1.aspx[^].
If you need to log the user also, that can make it more complicated depending on your application's authentication scenario.
Here is a good comparison of auditing methods you can deal with: http://www.slideshare.net/sqlserver.co.il/a-comparative-analysis-of-auditing-solutions-in-sql-server[^]
 
Share this answer
 
v2
You should have a ModifiedDate Column in the table, where your data is getting saved.

For any operation(Edit/Update) on a row of that table, update that column with <a href="http://msdn.microsoft.com/en-us//library/system.datetime.now.aspx">DateTime.Now</a>[<a href="http://msdn.microsoft.com/en-us//library/system.datetime.now.aspx" target="_blank" title="New Window">^</a>], so that it will contain the DateTime at that particular event.
 
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