Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Bases de datos > Tablas planas
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 17-11-2005
Gabriel2 Gabriel2 is offline
Miembro
 
Registrado: sep 2004
Posts: 108
Poder: 20
Gabriel2 Va por buen camino
Crear índice en runtime

Para crear una tabla paradox en tiempo de ejecución utilizó un código similar a este:

Código Delphi [-]
 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...

Última edición por dec fecha: 17-11-2005 a las 21:44:04. Razón: ¡¡Encerrad el código fuente entre las etiquetas [DELPHI] ... [/DELPHI]!!
Responder Con Cita
  #2  
Antiguo 17-11-2005
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Poder: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
Cita:
Empezado por Gabriel2
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
Responder Con Cita
  #3  
Antiguo 17-11-2005
Gabriel2 Gabriel2 is offline
Miembro
 
Registrado: sep 2004
Posts: 108
Poder: 20
Gabriel2 Va por buen camino
Solución

Código:
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...
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 02:28:13.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi