PDA

Ver la Versión Completa : Crear una B.D. con paradox


CFPA86
04-09-2003, 21:42:03
Hola foristas de Delphi.


Como creo y destruyo en tiempo de ejecuccion, mediante codigo una base de datos en paradox donde le pueda agregar campos.

Les agradezco la atencion que le puedan ofrecer a este mensaje, gracias

Gregory Mazon
05-09-2003, 01:17:26
Espero te sirva
para Crearla :

Procedure Crea;
FBase := TTable.Create(Self);
with FBase do begin
Active := False;
TableType := ttParadox;
TableName := 'Temporal.db'

if not FBase.Exists then begin
with FieldDefs do begin
Clear;
with AddFieldDef do begin
Name := Codigo';
DataType := ftString;
Size := 15;
end;
with AddFieldDef do begin
Name := 'Descripcion';
DataType := ftString;
Size := 30;
end;
with AddFieldDef do begin
Name := 'Cantidad';
DataType := ftFloat;
end;
with AddFieldDef do begin
Name := 'Precio';
DataType := ftFloat;
end;
with AddFieldDef do begin
Name := 'Importe';
DataType := ftFloat;
end;
end;
CreateTable;
end;
end;


Y PARA DESTRUIRLA :


procedure xxx.FormClose(Sender: TObject; var Action: TCloseAction);
Var
F : TextFile;
begin
inherited;
if Assigned(Fbase) Then Begin
AssignFile(F, FBase.Database.Directory+'\'+FBase.TableName);
FBase.Close();
Erase(F);
End;
Action := caFree;
end;

CFPA86
05-09-2003, 15:41:18
Hola foristas; gracias a todos y especialmente a Gregory, voy a probar este codigo si me funciona si es asi se los dire por este mismo medio.

Muchas gracias

CFPA86
06-09-2003, 15:19:04
Se puede dar este mensaje como terminado, me funciona este codigo, gracias por todo.