![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Buscar | Temas de Hoy | Marcar Foros Como Leídos |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
#3
|
|||
|
|||
|
otra forma de hacerlo...
function TFCrea.nuevoCampo(campo: tipoCampo; Tab, sNom: string; Lon: integer):boolean; var nuevo : boolean; begin nuevo := false; Tabla.TableName := Tab; try Tabla.Open; if tabla.FindField(snom) = nil then begin nuevo := true; tabla.Close; try case campo of tpLogico : q.sql.Strings[0] := 'alter table "' + Tab + '" add ' + sNom + ' boolean'; tpFecha : q.sql.Strings[0] := 'alter table "' + Tab + '" add ' + sNom + ' date'; tpCadena : q.sql.Strings[0] := 'alter table "' + Tab + '" add ' + sNom + ' char(' + inttostr(lon) + ')'; tpEntero : q.sql.Strings[0] := 'alter table "' + Tab + '" add ' + sNom + ' integer'; tpIncermen : q.sql.Strings[0] := 'alter table "' + Tab + '" add ' + sNom + ' autoinc'; tpReal : q.sql.Strings[0] := 'alter table "' + TaB + '" add ' + sNom + ' numeric'; tpmemo : q.sql.Strings[0] := 'alter table "' + TaB + '" add ' + sNom + ' blob(100)'; end;//case q.ExecSQL; except MsgLista('ERROR : Crear Campo: ' + sNom + '/ Tabla: '+Tab); nuevo := false; //** si hay algun error marcar como no actualizado ** end; end else Tabla.Close; if nuevo then MsgLista('OK : Creado campo: ' + sNom + '/ Tabla: '+Tab); nuevoCampo := nuevo; except MsgLista('ERROR : Crear Campo: ' + sNom + '/ Tabla: '+Tab); nuevo := false; end; end; procedure TFCrea.MsgLista(mensaje:string); begin Lista.Items.Add(mensaje); Lista.Update; end; y para llamar a la funcion nuevoCampo(tpreal,'tabla.db','campo',0); Salu2. P0Tlanos |
| Herramientas | Buscar en Tema |
| Desplegado | |
|
|
|