Page 1 of 1

TimeStamp

Posted: Fri 30 Dec 2005 07:29
by Sawlmgsj
Do you know how to collect the value in a TimeStamp field?
My intention is to use this value to check whether another user has updated the field whilst I have been reviewing it - and then I go to make my update.

My TimeStamp field is called Stamp.
I could not find a Delphi type to copy it into directly, so I tried to convert it to a DateTime with this code:

myDateTime:=SQLTimeStampToDateTime(MSQuery1.FieldByName('Stamp').AsSQLTimeStamp);

This returns the error: "Cannot access field Stamp as type SQLTimeStamp".

Any help would be appreciated.

Thanks,
Steve.

Posted: Fri 30 Dec 2005 10:56
by Ikar
Please read SDAC help about MSQuery.Options.CheckRowVersion property.
Please note: in MS SQL you can't decode timestamp field.

CheckRowVersion

Posted: Wed 11 Jan 2006 16:44
by Sawlmgsj
I have read your help but cannot understand it.

I want to implement Optimistic locking.
If I set MsQuery1.Options.CheckRowVersion:=True
Also have a TimeStamp and ID (autoinc) fields in the table.
How do I actually check whether the row has been updated by another user?

Do you have any sample code to illustrate this operation, so that I can give the user a choice of whether to abandon his update or overwrite the update made by the other user?

Thanks for your help.
Steve.

Posted: Thu 12 Jan 2006 10:34
by Ikar
> How do I actually check whether the row has been updated by another user?

Setting CheckRowVersion to True is enough.

> Do you have any sample code to illustrate this operation

We don't have samples other than included in the installation package.

Optimistic locking - once again

Posted: Sat 08 Dec 2007 17:31
by mfg
I set CheckRowVersion to True in your example SdacDemo-> CachedUpdates, I added a TimeStamp field to the dbo.emp table, I opened 2 copies of sdacDemo and I was editing the same record in the same time. Nothing happend.
In that case should I get any error message or there is another way to catch this event ?

I use Sdac 4.30, Delphi 5.
Thanks for your help.
ZS

Posted: Thu 20 Dec 2007 11:57
by Antaeus