Ver Mensaje Individual
  #4  
Antiguo 14-11-2015
marvajes marvajes is offline
Registrado
NULL
 
Registrado: nov 2015
Posts: 6
Reputación: 0
marvajes Va por buen camino
Muchas gracias por la ayuda.

Muchas gracias por tu ayuda AgustinOrtu, primeramente por la corrección, pues tenia una idea errónea del uso de try finally.
Con el tema de bajar el archivo, solo hice una pequeña modificación al código.

Insertar el archivo en la Base de datos
Código Delphi [-]
  var
  LStream: TStream;
begin
   SQL.SQL.Add('INSERT INTO ARCHIVOS VALUES(:ID,ATO)');
   SQL.ParamByName('ID').AsInteger:=1;
   SQL.ParamByName('DATO').LoadFromFile('1.pdf',ftblob);
    try
      Sql.ExecSQL;
    finally
        //ERROR
    end;
end;

Recuperar el archivo y almacenar en disco duro
Código Delphi [-]
var
  LStream: TStream;
begin
  LStream := TFileStream.Create('1.pdf', fmOpenRead);
    Sql.SQL.Add('SELECT * FROM ARCHIVOS');
  try
      SQL.Open; // abrimos
   TBlobField(SQL.FieldByName('NOMBRE')).SaveToFile('C:\u\1.pdf');
  finally
    LStream .Free;
  end;
end;

Cabe mencionar que inicialmente al recuperar el archivo, este aparecia corrupto o no mostraba el contenido y esto debido justamente como indicaste el limite, utilizado inicialmente BLOB ≈ 64KB, MEDIUMBLOB ≈ 16MB and LONGBLOB ≈ 4GB. Lo deje en MEDIUMBLOB y perfecto.
Muchas gracias por la ayuda amigo!.
Saludos.
Responder Con Cita