Board index » delphi » Trouble getting State & using Emptytable method

Trouble getting State & using Emptytable method

Hi
I want to use the Emptytable Method to clear records out of a grid.
This is a local table no other systems have access to it.

First I'm having trouble getting access..  "Table is busy" error.
Also I'd like to have the tables state displayed on Label1 on the
form.

But  
 label1.caption:=Table1.state
Dosen't work.

Thank you
Phil

 

Re:Trouble getting State & using Emptytable method


Quote
Phillip Coomer wrote:

> Hi
> I want to use the Emptytable Method to clear records out of a grid.
> This is a local table no other systems have access to it.

> First I'm having trouble getting access..  "Table is busy" error.
> Also I'd like to have the tables state displayed on Label1 on the
> form.

> But
>  label1.caption:=Table1.state
> Dosen't work.

> Thank you
> Phil

Be careful, EmptyTable is used to Empty completly the table.
So
1) The Table.Exclusive property must be set to True.
2) The table must not be opened in Delphi while running at Design time.

And finally, if you only want to delete a view (some records and not the
whole table) use Table.Delete, it's better and it's also fast.

Re:Trouble getting State & using Emptytable method


Well the second question is interesting. If you want show the table
state, you must write this :

Case Table1.State of
dsEdit : Label1.Caption:='Editing';
...
End;

What you write i exactly the same as : Label1.Caption:=10; !

Bye.

Quote
Phillip Coomer wrote:

> Hi
> I want to use the Emptytable Method to clear records out of a grid.
> This is a local table no other systems have access to it.

> First I'm having trouble getting access..  "Table is busy" error.
> Also I'd like to have the tables state displayed on Label1 on the
> form.

> But
>  label1.caption:=Table1.state
> Dosen't work.

> Thank you
> Phil

Re:Trouble getting State & using Emptytable method


First, keep in mind that the EmptyTable method DELETES records from
the table. If this is what you want to do, then do the following
before using EmptyTable...

        Table1.Close; // same as Active:=True...
        Table1.EmptyTable;

No more records in the table, but the file structure still exists on
the drive (for future use?). If you want to DELETE the table then use
the Table1.Delete method (remember to close the table first or you'll
get an error.)

If you just want to turn off the grid view you can do lots of
things...

        Filter the data,
        DisableControls
        Change the Grid's DataSource to ''

You mentioned you wanted to clear records from a GRID. EmptyTable
DELETES records, not just the grid's view of them. Are you sure you
want to do that?

As far as the "State" of the table goes, use a CASE statement to test
the state. You cannot directly redirect the STATE type to a
lable.Caption because one is a dsState (an element in an array of
States) and the other is a STRING.

There's already a reply on use of the case statement here, but you
might want to test the Table's state or the Datasource's state. Check
out both of them. DataSource will tell you the state of each field and
the TTable.State will tell you the status of the Record / table.

Bill Artemik
Programmer / Analyst
Wakefield Engineering, Inc.

arte...@worldnet.att.net

On Tue, 03 Feb 1998 14:12:04 GMT, Cr...@craftmark.com (Phillip Coomer)
wrote:

Quote
>Hi
>I want to use the Emptytable Method to clear records out of a grid.
>This is a local table no other systems have access to it.

>First I'm having trouble getting access..  "Table is busy" error.
>Also I'd like to have the tables state displayed on Label1 on the
>form.

>But  
> label1.caption:=Table1.state
>Dosen't work.

>Thank you
>Phil

Bill
-------------------------------
Programmer/Analyst
Wakefield Engineering, Inc.
arte...@worldnet.att.net

"There are THREE kinds of people in the world...
     Those that can count and those that can't."

Other Threads