[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • Last Modified:

Detecting record lock in Paradox Table

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
ray3898
Asked:
ray3898
1 Solution
 
Gerhard100198Commented:
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
 
kretzschmarCommented:
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
 
ray3898Author Commented:
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
 
Ronald BusterCommented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now