Clientdataset 读取SQL图片字段后在image 显示不完整

解决方案 »

  1.   

    var
    MS:TMemoryStream;
    JpgFile:TjpegImage;
    begin
              with clientdataset2 do
              begin
                    close;
                    clientdataset2.CommandText:=('select * from cp_name_image where 货品名称='''+cp_namelrADOquer.FieldValues['货品名称']+''' ');
                    open;
              end;
    if clientdataset2.IsEmpty=false then begin
        MS:=TMemoryStream.Create ;
        JpgFile:=TjpegImage.Create ;
        TBlobField(clientdataset2.FieldByName('图片')).SaveToStream(MS);
        MS.Position :=0;
        jpgfile.LoadFromStream(MS);
        image1.Picture.Assign(JpgFile);
    end
    else begin
      image1.Picture :=nil;
    end;
    end;
      

  2.   

    image1 的 Strew 属性打开