Add new index file at runtime

Posted in Databases

Use AddIndex method of Table component. First parameter is a name of new index, second parameter is a field of database.

procedure TForm1.Button1Click(Sender: TObject);
var
  Str: string;
begin
  Str:='Area';
  Table1.AddIndex(Str, Str, [ixUnique]);
end;