Solved

How to check if record is locked

Posted on 1997-12-04
3
175 Views
Last Modified: 2010-04-04
How can you check to see whether a record that you are about to write to is locked by another user?  If I have to check for an exception, then which one should I check for (EConvertError, E....)?  What I want to do is rollback a Transaction if my write to a table fails.
0
Comment
Question by:tdiamond
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
Waldek earned 100 total points
ID: 1352908
You must check for exception EDBEngineError and then
test ErrorCode like this
 case Errors[0].ErrorCode of
  DBIERR_LOCKED:{ Action , if lock failed}
  DBIERR_UNLOCKFAILED: { Action , if unlock failed}
 end;
0
 

Author Comment

by:tdiamond
ID: 1352909
What you gave me is a great start but it doesn't seem to compile (unless I'm doing something wrong). The following code works but will report an error when any kind of EDBEngineError occurs.  Can you tell me (or show me) how to modify it to test specifically for a locked record?  It would help me out a lot.

procedure TFRMMain.Button2Click(Sender: TObject);
begin
  try
    ItemsTable.edit;
    ItemsTable['Test']:=1;
  except on EDBEngineError do showmessage('Record is locked !');
  end;
end;
0
 
LVL 2

Expert Comment

by:Waldek
ID: 1352910
check function from unit BDE : DBIIsRecordLocked
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JSON on ISAPI REST Server using Delphi 2 229
Print Graphic and Text to Epson TM-T88v 12 176
Base1 Encode/Decode 3 67
How to load 2 images in same column in Delphi 2 32
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now