TimeStamp

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Sawlmgsj
Posts: 35
Joined: Thu 11 Nov 2004 08:35

TimeStamp

Post by Sawlmgsj » Fri 30 Dec 2005 07:29

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.

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Fri 30 Dec 2005 10:56

Please read SDAC help about MSQuery.Options.CheckRowVersion property.
Please note: in MS SQL you can't decode timestamp field.

Sawlmgsj
Posts: 35
Joined: Thu 11 Nov 2004 08:35

CheckRowVersion

Post by Sawlmgsj » Wed 11 Jan 2006 16:44

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.

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Thu 12 Jan 2006 10:34

> 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.

mfg
Posts: 10
Joined: Wed 03 Oct 2007 13:49
Location: Zabrze

Optimistic locking - once again

Post by mfg » Sat 08 Dec 2007 17:31

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

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Thu 20 Dec 2007 11:57


Post Reply