Board index » delphi » Check if table is open

Check if table is open

How do I check whether a Paradox table is opened. (Using D5)

Thanks,

Tove

 

Re:Check if table is open


Thath's simple:

use property Table.Active

Rosen Marinov

Quote
"Tove" <tove.bjornb...@c2i.net> wrote in message

news:8ljj17$ie31@bornews.borland.com...
Quote
> How do I check whether a Paradox table is opened. (Using D5)

> Thanks,

> Tove

Re:Check if table is open


Yeah, it works fine when I have only one instanse of the application
running. If I start one instance, then start another and check whether a
spesific table already is open, it says it's not open although it was opened
by the first user. (Trying to avoid 2 instances working on the same table
here).  I'm using D5 and Paradox tables.

Thanks,
Tove

Quote
"Rosen Marinov" <ro...@brainstorm.bg> wrote in message

news:397d6216_2@dnews...
Quote
> Thath's simple:

> use property Table.Active

> Rosen Marinov

> "Tove" <tove.bjornb...@c2i.net> wrote in message
> news:8ljj17$ie31@bornews.borland.com...
> > How do I check whether a Paradox table is opened. (Using D5)

> > Thanks,

> > Tove

Re:Check if table is open


The only way to do that is to set the exclusive property of the TTable
to true.   Any subsequent attempt to open the underlying table will
then fail.   Set exclusive back to false again afterwards if shared
access will be required later in the same session.

I use the following function, called like this:  

if ExclusiveOpen(Table1) then
          do_your_stuff_here
else bail_out_here;

function ExclusiveOpen(SubjectTable: TTable):boolean;
{try to open a table for exclusive use and report result}
var
  SuccessFlag: Boolean;  {indicates successful exclusive open}
begin
  SuccessFlag := False;
  SubjectTable.Active := False; {first ensure table not already open}
  while not SuccessFlag do
  begin
    try
      {Try to open the table exclusively}
      SubjectTable.Exclusive := True;
      SubjectTable.Active := True; {see if it will open}
      SuccessFlag := True;  {if no error}
    except
      on EDatabaseError do
        { ask if we should retry.  if not, break out of loop}
        if MessageDlg('The file is in use - Try again?',
          mtError,[mbOK, mbCancel], 0) <> mrOK then
        begin
          {ensure it is closed before breaking out
          (probably not necessary as the open must have failed)}
          SubjectTable.Active := False;
          SubjectTable.Exclusive := False;
          break;
        end;
    end;
  end;
  result := SuccessFlag;
end;

On Tue, 25 Jul 2000 13:29:53 +0200, "Tove" <tove.bjornb...@c2i.net>
wrote:

Quote
>Yeah, it works fine when I have only one instanse of the application
>running. If I start one instance, then start another and check whether a
>spesific table already is open, it says it's not open although it was opened
>by the first user. (Trying to avoid 2 instances working on the same table
>here).  I'm using D5 and Paradox tables.

Re:Check if table is open


Try to open the table with a TTable whose Exclusive property is set to True.

--
Bill Todd (TeamB)
(Questions received via email cannot be answered.)

Other Threads