HELP: MSSQL LockType and CursorType

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
JasonClark
Posts: 1
Joined: Fri 04 Sep 2009 14:58

HELP: MSSQL LockType and CursorType

Post by JasonClark » Thu 08 Oct 2009 13:17

Hello

First of all the information about my test system:

DBMS: MSSQL 2005 with SP3
Compiler: Delphi 2009
OS: Windows Vista Ultimate and Windows XP Pro

Case example:
I have written a application with TUniConnection (connected to MSSQL 2005 database), TUniQuery (connected to TUniConnection and SQL property with SQL syntax to needed table) and TSQLServerUniProvider. There is also a DBGrid on the application form which shows the content of the resultset of the TUniQuery connected via TDataSource.

What i want to do now is that when User A works on another PC than me (User B) and we both have a connection to the same table, then when User A changes one record i want that the record is locked for any other user (e.g. User B) as long as User A has not posted the changes or canceled it. And the other thing is when User A post his changes i want that User B could see automatically the changes of the record.

Hope someone could help me out and point me into the right direction. Or it would be great if someone could send me a demo application or maybe inform me which demo application of UniDAC does the case example above.

Thanks a lot for your help in advance!

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Fri 09 Oct 2009 08:24

You can enable locking of the records that are being edited by setting the LockMode property of TUniQuery to lmPessimistic.

Set roBeforeEdit in RefreshOptions. Record will be refreshed when you call Edit. So a user will always see actual data when editing a record. You can also call the Refresh method periodically using the TTimer component.

Post Reply