Edit date in edit view asp.net mvc

Hi,

I am using Linq to Sql. I am inserting data in the table using create view. Date column have default value = getdate() in the sql server database. So automatically, it will insert the server date.

But problem is, when I update the data using edit view and save view , it will not update the date in the table.

How to update the date on every insert in asp.net mvc.

Thanks
Saroj13Asked:
Who is Participating?
 
Carl TawnSystems and Integration DeveloperCommented:
You may find it's easier to implement that as a trigger on the database table rather than trying to do it through your app.
0
 
Saroj13Author Commented:
How to do that on the database table?
0
 
Carl TawnSystems and Integration DeveloperCommented:
Something like the following should do:
CREATE TRIGGER trgUpdateDate
ON YourTable
AFTER INSERT, UPDATE
AS
     UPDATE YourTable SET YourDateColumn = GETDATE()
           WHERE YourTable.YourKeyField = Inserted.YourKeyField

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.