Código Delphi
[-]
Var MS : TMemoryStream;
begin
conexiodb.Conectar_Mysql;
sqlejecuta:=TZQuery.Create(nil);
with sqlejecuta do
begin
Connection:= Conexion;
Close;
SQL.Clear;
SQL.Add('INSERT INTO PERSONAL(CEDULA,NOM_COMP,DIRECCION,TELF_MOVIL,');
SQL.Add('TLF_LOCAL,CARGO,FOTO,DEPARTAMENTO_IDDEPART,');
SQL.Add('PARAMETRO_IDPARAMETRO,TIP_EMPLEADO_IDTIP_EMP,ID_USER)');
SQL.Add('VALUES(:CEDULA,:NOM_COMP,IRECC,:MOVIL,:FIJO,:CARGO,');
SQL.Add(':FOTO,EPTO_ID,:PARAM_ID,:TIP_EMPL,:USER_ID)');
ParamByName('CEDULA').AsString:= Trim(trif.Text);
ParamByName('NOM_COMP').AsString:= Trim(tnom_per.Text);
ParamByName('DIRECC').AsString:= Trim(mdir.Text);
ParamByName('MOVIL').AsString:= Trim(tmovil.Text);
ParamByName('FIJO').AsString:= Trim(tntlf.Text);
ParamByName('CARGO').AsString:= Trim(tnom_cargo.Text);
ParamByName('DEPTO_ID').AsInteger := middepart;
ParamByName('PARAM_ID').AsInteger:= midparametro;
ParamByName('TIP_EMPL').AsInteger:= midtip_emp;
ParamByName('USER_ID').AsString:= tid_user;
MS:= TMemoryStream.Create;
try
Image1.Picture.Bitmap.SaveToStream(MS);
MS.Position:= 0;
ParamByName('FOTO').LoadFromStream(MS, ftBlob);
finally
MS.Free;
end;
try
ExecSQL;
MessageDlg('Registro Almacenado con exito',mtInformation,[mbOK], 0);
exit;
except
on E: Exception do
begin
MessageDlg('Problemas de conexion con la base de datos',mtWarning,[mbOK], 0);
exit;
end;
end;
end;
Muchas gracias
ecfisa funciona perfecto ya solo agregue otra excepcion a ExecSQL; y antes con Parametros no me funcionaba era por esta linea:
Código Delphi
[-]Params.CreateParam(ftBlob,'foto', ptInput);
como escribi anteriormente tengo que leer mas sobre el uso de parámetros de nuevo muchas Gracias estoy haciendo esto para tratar pasar un sistema hecho en vfp a pascal ya me falta los reportes que actualmente los estoy haciendo en fortesreport4lazarus claro ya poco a poco haré un código mas limpio