Create DB file at runtime

Posted in Databases

This problem is not so difficult. See example below.

procedure TForm1.Button1Click(Sender: TObject);
begin
  with Table1 do
  begin
    Active:=False;
    DatabaseName:='DBDEMOS';
    TableType:=ttParadox;
    TableName:='NewTable';
    with FieldDefs do
    begin
      Clear;
      Add('Field1',ftInteger,0,True);
      Add('Field2',ftString,30,False);
    end;
    with IndexDefs do
    begin
      Clear;
      Add('','Field1',[ixPrimary,ixUnique]);
    end;
    CreateTable;
  end;
end;