Product Documentation

VCL/CLX Developers Guide

Previous Topic

Next Topic

Deleting a Table

A table that is deleted from the database is eliminated from the database dictionary (the user is no longer able to open it) and also from disk. Use the following procedure to delete a table from a database:

  1. Log on to a c-tree Plus session (please refer to “Log On to c-tree”).
  2. Connect to a database (please refer to “Connecting to a database”).
  3. Drop a TCtTable component on a form.
  4. Set the Database property to the database component.
  5. Set the Table property to the table name.
  6. Set the Password property if the table was created with a password.
  7. Call the DeleteTable() method.

The code excerpts below represent a table being deleted from a database at run time. There is no way to delete a table at design time. Do not delete a table physically from disk, since it will be kept in the database dictionary. This is the correct operation that should be done in order to remove a table from the database, and physically delete it from the disk.

Delphi Example


procedure Form1.DeleteTable();

begin

try

CtTable1.Table := 'MyTable';

CtTable1.Database := CtDatabase1;

CtTable1.DeleteTable();

except

on E : ECtError do

Application.ShowException(E);

end;

end;

C++ Example


void Form1::DeleteTable()

{

try

{

CtTable1->Table = "MyTable"

CtTable1->Database = CtDatabase1;

CtTable1->DeleteTable();

}

catch (ECtError& E)

{

Application->ShowException(&E);

}

}

TOCIndex