...ein Bild (JPEG) in einem Blob-Feld mit SQL laden?

Autor: Bob Villiers

Kategorie: Datenbanken

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