Delphi��Image存入读取MySQL数据库


本文整理自网络,侵删。

 

存入

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 如何用程序控制禁止和起用上网?

相对完整的多线程idhttp文件下载代码

Delphi 设置文本框中光标的位置在最后

Delphi unigui获取连接的客户端列表

Delphi 在memo查找字符并定位

Delphi qr /条形码扫描仪应用示例代码(使用zxing,tframestand)

Delphi fmx手机app,如何下载网站图片而不卡界面

Delphi读写firebird二进制数据

Delphi与sqlite3数据库

Delphi firemonkey应用程序中显示时隐藏虚拟键盘

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...