Board index » delphi » Force exclusive Lock on a Paradox table?

Force exclusive Lock on a Paradox table?

Hi

Is it possible to force an exclusive lock on a Paradox table even if it is
still open by other users on a network?

From time to time I have found it necessary to rebuild a table because of
corruption and it's very annoying to have to run round the office to see
who's got the table open and get them to close it.  Obviously I wouldn't
want a user to lose a record they are adding to the table, but if users only
have it open to browse which is commonly the case in our set-up, can I force
it closed so that I can perform the rebuild?

Any help appreciated.
Regards

Joe Caws

 

Re:Force exclusive Lock on a Paradox table?


Try this:

    Table1.LockTable(ltReadLock);
    try
        Table1.LockTable(ltWriteLock);
        try
            ... Do whatever you want ...
        finally
            Table1.UnlockTable(ltWriteLock);
        end;
    finally
        Table1.UnlockTable(ltReadLock);
    end;

Re:Force exclusive Lock on a Paradox table?


No. Unfortuanately exlusive means that no other user can have the table open
and there is no way around this with Paradox tables.

--
Bill

Re:Force exclusive Lock on a Paradox table?


What you can do is to write some code that enumerates and lists the network
IDs logged on to a particular alias. You will at least then know whose
office to run to.

I'm away for a few days, but if you want, I can post the code next Thursday
when I'm back.

--
Steve F (Team B)

Re:Force exclusive Lock on a Paradox table?


Thanks for all the replies...
- Knowing who is most likely to have the tables open would certainly help.

On the other hand, I say "exclusive lock" as that is what TUtility
seems to require to rebuild a table. Is there anything out there that will
rebuild or repair a
corrupted table without an exclusive lock? How does anybody else get around
this? Obviously in a working enviroment, users are accessing tables all the
time, so obtaining an exclusive lock on any one of them is right old pain,
especially if its a regularly used table (and always gets a few people
moaning around the office because they can't use it for a few minutes ;-)

My app does open and close the tables depending on what the user needs to
perform a specific operation, but you can always bank on somebody leaving a
table or two open because they were browsing say a list of customers and
just left it on the screen without exiting.

Any ideas?
Thanks

Joe

Quote
"Joe Caws" <nospam-webmas...@eastleigh-services.co.uk> wrote in message

news:3afbc33f$1_2@dnews...
Quote
> Hi

> Is it possible to force an exclusive lock on a Paradox table even if it is
> still open by other users on a network?

> From time to time I have found it necessary to rebuild a table because of
> corruption and it's very annoying to have to run round the office to see
> who's got the table open and get them to close it.  Obviously I wouldn't
> want a user to lose a record they are adding to the table, but if users
only
> have it open to browse which is commonly the case in our set-up, can I
force
> it closed so that I can perform the rebuild?

> Any help appreciated.
> Regards

> Joe Caws

Re:Force exclusive Lock on a Paradox table?


If the application and hardware are stable and configured correctly I would
not expect more than one corrupt table per year, if that much. There is no
way to rebuild a table without an exclusive lock. Long term you might
consider moving your app to a database server since a server is much less
prone to file corruption.

--
Bill

Re:Force exclusive Lock on a Paradox table?


Thanks for the advice.

Joe Caws

Quote
"Joe Caws" <nospam-webmas...@eastleigh-services.co.uk> wrote in message

news:3afbc33f$1_2@dnews...
Quote
> Hi

> Is it possible to force an exclusive lock on a Paradox table even if it is
> still open by other users on a network?

> From time to time I have found it necessary to rebuild a table because of
> corruption and it's very annoying to have to run round the office to see
> who's got the table open and get them to close it.  Obviously I wouldn't
> want a user to lose a record they are adding to the table, but if users
only
> have it open to browse which is commonly the case in our set-up, can I
force
> it closed so that I can perform the rebuild?

> Any help appreciated.
> Regards

> Joe Caws

Other Threads