A table may belong to multiple databases. A table may be created in one database and later added to a second one. Current or new c-tree Plus files may also be added to a database, with a few exceptions (see the discussion in Chapter 12 “Existing c-tree Plus Data Considerations” in the c-tree Plus Quick Start and Product Overview Guide). Use the following procedure to add an existing table named MyOldTable (in the specified directory) to a database in run time:
The code excerpts below represent a table being added to a database at run time. There is no way to add a table at design time.
Delphi Example
procedure Form1.AddExistingTable();
begin
try
CtTable1.Table := MyOldTable;
CtTable1.Database := CtDatabase1;
{$IFDEF WIN32} // Windows path
CtTable1.Directory := 'C:\Data';
{$ELSE} // Linux path
CtTable1.Directory := '/home/Data';
{$ENDIF}
CtTable1.AddTable();
except
on E : ECtError do
Application.ShowException(E);
end;
end;
C++ Example
void Form1::AddExistingTable()
{
try
{
CtTable1->Table = "MyOldTable"
CtTable1->Database = CtDatabase1;
#ifdef __WIN32__ // Windows path
CtTable1->Directory = "C:\\Data";
#else // Linux path
CtTable1->Directory = "/home/Data";
#endif
CtTable1->AddTable();
}
catch (ECtError& E)
{
Application->ShowException(&E);
}
}