Skip to content

Instantly share code, notes, and snippets.

Created January 24, 2017 11:35
Show Gist options
  • Save anonymous/44a2bb356ddbd0cb30b4c7203a6316cd to your computer and use it in GitHub Desktop.
Save anonymous/44a2bb356ddbd0cb30b4c7203a6316cd to your computer and use it in GitHub Desktop.
function ToString(Stream:TMemoryStream):string;
begin
Stream.Seek(0,0);
SetString(Result, PChar(Stream.Memory), Stream.Size);
end;
procedure Main();
begin
qry:=TQuery.Create(Props.ThreadSafeConnection);
ms:=TMemoryStream.Create;
bmp:=TBitmap.Create;
try
bmp.LoadFromFile('c:\somefile.bmp');
bmp.SaveToStream(ms);
ms.Seek(0,0);
qry.SQL.Text:='update my_table set icon=:icon';
qry.ParamByName('icon', true).AsBlob:=ToString(ms);
qry.ExecSQL;
finally
qry.Free;
ms.Free;
bmp.Free;
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment