Board index » delphi » How to check if you can edit a record in a multiuser environment

How to check if you can edit a record in a multiuser environment

I have developed an application based on a DBase database. The system is
to be ran by multiple users.

My problem is:

I'm standing on record 45 (for example) on one computer and having the
record in edit mode.

Then I go to another computer and go to then same record (no 45) the BDE
returns an error message when I try to put a record in editmode (
Dataset.edit ) - 'Record locked by another user' - which is correct.

But I wonder if there is a way for me to check if the record is 'Record
locked by another user' before I try to put it in editmode???????
(CanModify is not working here) - The BDE error is quite fatal to my
program because the BDE error causes my program to skip the rest of the
code of the running event.

If the check is'nt possible is the only solution I have to restructure
my program (Try - Except - Finally)?

Hi from Mona

 

Re:How to check if you can edit a record in a multiuser environment


Use try except (my opinion).

FV

Re:How to check if you can edit a record in a multiuser environment


try
  Table1.Edit;
except
  ...do whatever...
end; //try

--
Bill

(TeamB cannot answer questions received via email.)
(To contact me for any other reason remove nospam from my address)

Re:How to check if you can edit a record in a multiuser environment


Quote
>If the check is'nt possible is the only solution I have to restructure
>my program (Try - Except - Finally)?

That is the way you should have done it from the start.

--
Brian Bushay (TeamB)
Bbus...@DataGuidance.com

Re:How to check if you can edit a record in a multiuser environment


In Clipper I always do this
do while !WorkArea->(Rlock());enddo
Is there no way to do the same in Delphi?
Like:
 while Tbl.State <> dsEdit do Tbl.Edit;

Ross.
Brian Bushay TeamB <BBus...@DataGuidance.com> wrote in article
<35297738.47196...@forums.borland.com>...

Quote

> >If the check is'nt possible is the only solution I have to restructure
> >my program (Try - Except - Finally)?

> That is the way you should have done it from the start.

> --
> Brian Bushay (TeamB)
> Bbus...@DataGuidance.com

Re:How to check if you can edit a record in a multiuser environment


Ross Perry wrote<01bd5f0d$f5a8dce0$8e422ec6@AnonymousIPX>...

Quote
>In Clipper I always do this
>do while !WorkArea->(Rlock());enddo
>Is there no way to do the same in Delphi?
>Like:
> while Tbl.State <> dsEdit do Tbl.Edit;

while true do
try
  tbl.Edit;
  Break;
except
{can check what error or count for time limit here}
end;

Peter Yau

Re:How to check if you can edit a record in a multiuser environment


Quote
>In Clipper I always do this
>do while !WorkArea->(Rlock());enddo

You are not in Clipper any more and it is probably time to learn some
new habbits.

Quote
>Is there no way to do the same in Delphi?

I  do not do Clipper so I can't translate

Quote
>Like:
> while Tbl.State <> dsEdit do Tbl.Edit;

The problem here is that you will not be in state dsEdit until the
edit command succeds.

Try
   tbl.Edit
  {do something}
Except
  {Edit failed do something to recover}
end;

--
Brian Bushay (TeamB)
Bbus...@DataGuidance.com

Other Threads