..load a jpeg file into a blob field using SQL?

Author: Bob Villiers

Category: Database

procedure TForm1.Button1Click(Sender: TObject);
var
ms: TMemoryStream;
begin
if
OpenPictureDialog1.Execute then
begin
ms := TMemoryStream.Create;
try
ms.LoadFromFile(OpenPictureDialog1.FileName);
with Query1 do
begin
with
SQL do
begin
Clear;
Add('INSERT INTO "ImageTbl.db" (ImageFld)');
Add('VALUES (:param0 )');
end;
Query1.ParamByName('param0').SetBlobData(ms.Memory, ms.Size);
ExecSQL;
end;
finally
ms.Free;
end;
end;
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base