Click here to Skip to main content
15,905,563 members
Home / Discussions / C#
   

C#

 
AnswerRe: Need help for duplicate rows automatically inserted from front end. Pin
Dave Kreskowiak2-Feb-12 3:49
mveDave Kreskowiak2-Feb-12 3:49 
QuestionCall validation during setup Pin
iamdking1-Feb-12 20:20
iamdking1-Feb-12 20:20 
AnswerRe: Call validation during setup Pin
thatraja1-Feb-12 20:40
professionalthatraja1-Feb-12 20:40 
AnswerRe: Call validation during setup Pin
Abhinav S1-Feb-12 21:16
Abhinav S1-Feb-12 21:16 
QuestionSaveSetting Pin
Ian_urquhart1-Feb-12 1:35
Ian_urquhart1-Feb-12 1:35 
AnswerRe: SaveSetting Pin
Pete O'Hanlon1-Feb-12 2:28
mvePete O'Hanlon1-Feb-12 2:28 
GeneralRe: SaveSetting Pin
Ian_urquhart1-Feb-12 5:38
Ian_urquhart1-Feb-12 5:38 
GeneralRe: SaveSetting Pin
Pete O'Hanlon1-Feb-12 7:30
mvePete O'Hanlon1-Feb-12 7:30 
AnswerRe: SaveSetting Pin
Abhinav S1-Feb-12 3:15
Abhinav S1-Feb-12 3:15 
AnswerRe: SaveSetting Pin
BillWoodruff1-Feb-12 5:36
professionalBillWoodruff1-Feb-12 5:36 
GeneralRe: SaveSetting Pin
Ian_urquhart1-Feb-12 5:56
Ian_urquhart1-Feb-12 5:56 
GeneralRe: SaveSetting Pin
SledgeHammer011-Feb-12 6:27
SledgeHammer011-Feb-12 6:27 
QuestionHow to find if client is idle or not? Pin
sreenathpktr1-Feb-12 1:06
sreenathpktr1-Feb-12 1:06 
AnswerRe: How to find if client is idle or not? Pin
DaveAuld1-Feb-12 1:32
professionalDaveAuld1-Feb-12 1:32 
AnswerRe: How to find if client is idle or not? Pin
DaveyM691-Feb-12 3:21
professionalDaveyM691-Feb-12 3:21 
AnswerRe: How to find if client is idle or not? Pin
jschell1-Feb-12 10:10
jschell1-Feb-12 10:10 
Question[SOLVED] Checkbox Column - DatagridView Pin
AmbiguousName1-Feb-12 0:51
AmbiguousName1-Feb-12 0:51 
AnswerRe: Checkbox Column - DatagridView Pin
Eddy Vluggen1-Feb-12 9:55
professionalEddy Vluggen1-Feb-12 9:55 
AnswerRe: Checkbox Column - DatagridView Pin
AmbiguousName1-Feb-12 18:20
AmbiguousName1-Feb-12 18:20 
AnswerRe: Checkbox Column - DatagridView Pin
Abhinav S1-Feb-12 21:32
Abhinav S1-Feb-12 21:32 
AnswerRe: Checkbox Column - DatagridView Pin
AmbiguousName1-Feb-12 22:02
AmbiguousName1-Feb-12 22:02 
QuestionAuto-increment value on UPDATE Pin
Dewald31-Jan-12 21:41
Dewald31-Jan-12 21:41 
Do you guys know of any easy way to have one column in a table of which the value auto updates every time an UPDATE statement is called for a specific row?

Either one of the following two scenarios would be fine but I'm not sure what the easiest way would be of implementing it:

1. Let's say there's a column in the table called 'Version' (int). Every time an UPDATE statement is called, the value of the 'Version' column is automatically incremented by 1 for every row affected.

2. Let's say there's a column in the table called 'Modified' (datetime). Every time an UPDATE statement is called, the value of the 'Modified' column is automatically set to the current date and time. I have a similar concept to this in my DB with a column named 'Inserted' which has a default value of GetDate(). So for every INSERT into the table, the 'Inserted' column will automatically get the current date and time but I'd like to have something like this for UPDATE as well.

Any ideas? My best idea so far would be to create a trigger on the table, something as follows:
SQL
CREATE TRIGGER update_mytable
ON MyTable
FOR UPDATE
AS
BEGIN
    UPDATE MyTable
    SET Modified = GETDATE()
    WHERE RecordID IN (SELECT RecordID FROM INSERTED)
END


But I'm hoping that there might be a more elegant solution.
AnswerRe: Auto-increment value on UPDATE Pin
Pete O'Hanlon31-Jan-12 22:15
mvePete O'Hanlon31-Jan-12 22:15 
GeneralRe: Auto-increment value on UPDATE Pin
Dewald31-Jan-12 22:29
Dewald31-Jan-12 22:29 
AnswerRe: Auto-increment value on UPDATE Pin
Łukasz Nowakowski31-Jan-12 22:16
Łukasz Nowakowski31-Jan-12 22:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.