PDA

Ver la Versión Completa : Crear índice en runtime


Gabriel2
17-11-2005, 21:26:50
Para crear una tabla paradox en tiempo de ejecución utilizó un código similar a este:


procedure TForm1.Button1Click(Sender:TObject);
begin
if not Table1.Exists then
begin
Table1.Active := FALSE;
Table1.DatabaseName := 'Alias';
Table1.TableType := ttParadox;
Table1.TableName := 'Nombre de la Tabla';
with Table1.FieldDefs do
begin
Clear;
Add('IntegerField', ftInteger, 0, FALSE);
Add('StringField' , ftString , 30, FALSE);
Add('LogicalField', ftBoolean, 0, FALSE);
Add('FloatField' , ftFloat , 0, FALSE);
Add('DateField' , ftDate , 0, FALSE);
Add('TimeField' , ftTime , 0, FALSE);
end;
Table1.CreateTable;
end;
end;

Lo que no he podido hacer es crear un índice... alguién sabe cómo...

roman
17-11-2005, 21:46:22
Lo que no he podido hacer es crear un índice... alguién sabe cómo...

Pues no sé, me da que Table.AddIndex ha de servir de algo.

// Saludos

Gabriel2
17-11-2005, 22:19:00
procedure TForm1.Button1Click(Sender: TObject);
begin
if not Table1.Exists then
begin
Table1.Active := FALSE;
Table1.DatabaseName := 'C:\Directorio';
Table1.TableType := ttParadox;
Table1.TableName := 'Mi DB';
with Table1.FieldDefs do
begin
Clear;
Add('AutoInc', ftAutoInc, 0, true) ;
Add('StringField' , ftString , 30, FALSE);
Add('LogicalField', ftBoolean, 0, FALSE);
Add('FloatField' , ftFloat , 0, FALSE);
Add('DateField' , ftDate , 0, FALSE);
Add('TimeField' , ftTime , 0, FALSE);
end;
Table1.IndexDefs.Clear;
Table1.IndexDefs.Add('', 'AutoInc', [ixPrimary]);
Table1.CreateTable;
end;
end;


Así me funcionó. Gracias...