where and how to run update query
Posted on 2009-02-17
Im using VWD 2008 (VB) / sql2008 express.
I have a formview that allows me to add add a small customer activity record each time we talk to our customers.
fields are: Client_Id, Activity, Start_Date, End_Date
Now my question is this - when I create a new activity record I would like to 'close' the previous record by automatically entering an End_Date = Now() on the previous record for this customer.
I guess the sql syntax would be as follows -
UpdateCommand="UPDATE [Client_Activity] SET [end_date] = now() WHERE [client_id] = @client_id AND [end_date] IS NULL"
But where would I put this? In a function? and where would I run it? Because it needs to run just before the new record gets inserted. I can supply the code if it helps but this form really is as simple as it sounds.