Solved

Detecting record lock in Paradox Table

Posted on 1998-11-30
4
202 Views
Last Modified: 2010-04-04
I am writing an multi-tier application using Delphi3 C/S version.  Is there any way I can detect from client A if a record has been locked due to editing by any other clients ?
0
Comment
Question by:ray3898
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Expert Comment

by:Gerhard100198
ID: 1348702
How about this:

Write a function that accepts the TDataSet name as a parameter and will return a TRUE value if the record is locked.

Then try and place the dataset in edit mode within a try except error handler. You could analyse the error in more detail to trap specifically for a situation where the record is locked. This function will however tell you if it is possible the allow the edit or not.

Example:

function IsLocked(TheDataSet: TDataSet): Boolean;
begin
   Result := False;
   try
     TheDataSet.Edit;
     TheDataSet.Cancel;
   Except
      Result := True;
   end;
end;

0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1348703
hi ray3898,

a other method

procedure TForm1.Button1Click(Sender: TObject); {Or other EventMethod}
var IsLocked : Bool;
begin
 if dbiisrecordlocked(table1.handle,IsLocked) = DBIERR_NONE then
   if IsLocked then showmessage ('Record Locked');
end;

This requires the unit BDE in the uses clause of your unit.

meikl
0
 

Author Comment

by:ray3898
ID: 1348704
It seems to me that your method is reside on the client side rather than the application side (back-end).  Since both client A and client B would receive a copy of the actual data (table1.db) from the application server, so all locking are taken place on the local copy but not on the actual table (am I right ?)  Therefore, what I want is when client A want to edit a record, the program will check directly from the application server to determine the current status of the record. Is it possible to do it and how can I do it ?

Thank you
0
 
LVL 3

Accepted Solution

by:
Ronald Buster earned 50 total points
ID: 1348705
I used to have the same problem, use the following statement,
just a code snippet from one of my sources

try

  ... whatever you want to do

except

   on E: EDBEngineError do

       begin

           ... record is proberly locked

       end;

end;

regards,

Cono
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

705 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