Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Edit date in edit view asp.net mvc

Posted on 2011-03-01
3
Medium Priority
?
489 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:Saroj13
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 35016614
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
 

Author Comment

by:Saroj13
ID: 35019878
How to do that on the database table?
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35020132
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question