存入
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;
注意,如果出現Got a packet bigger than ‘max_allowed_packet’ bytes
在My.ini加上
max_allowed_packet = 10M
Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号
执行时间: 0.040837049484253 seconds