本文整理自网络,侵删。
存入
var astream : Tmemorystream;
begin
AStream := TMemoryStream.Create;
try
Image1.Picture.Graphic.SaveToStream(AStream);
AStream.Position := 0;
if adoquery1.Active then
begin
adoquery1.Edit;
TBlobField(adoquery1.FieldByName('File')).LoadFromStream(AStream);
adoquery1.Post;
end;
finally
AStream.Free;
end;
取出
var
Ms:TStringStream;
jpg1:Tjpegimage;
begin
Ms := TStringStream.Create('');
jpg1 := Tjpegimage.create;
try
if adoquery1.Active then
begin
TBlobField(adoquery1.FieldByName('File')).SaveToStream(Ms);
Ms.Position := 0;
jpg1.LoadFromStream(ms);
image1.Picture.Bitmap.Assign(jpg1);
end;
finally
ms.Free;
jpg1.Free;
end;
注意,如果出?FGot a packet bigger than ‘max_allowed_packet’ bytes
在My.ini加上
max_allowed_packet = 10M
相关阅读 >>
Delphi 用 superobject 解析淘宝上的 json 数据
Delphi createthread的线程传参数(小熊论坛的)
Delphi winapi: gettopwindow - 获取指定窗口的子窗口中最顶层的窗口句柄
Delphi 用webbrowser给要访问的页面加上referer(来路)参数
更多相关阅读请进入《Delphi》频道 >>