我用BDE向sqlserver存储图片,如果图片稍大为什么总报invalid blob length阿,sql server中图片类型为image,改称binary后,就报invalid class typecast,请高手帮个忙啊,我是这样写的
procedure TForm1.savetodbClick(Sender: TObject); 
var
  strm: TMemoryStream; 
  ext: String;
begin
  if image1.picture.Graphic <> nil then 
  begin
    ext:=extractfileext(openpicturedialog1.FileName );
    strm := tmemorystream.Create ;
  try
    image1.Picture.Graphic.SaveToStream(strm);
    query1.Edit ;
    strm.Position :=0;  
    tblobfield(query1.FieldByName('photo')).LoadFromStream(strm);
    query1.Post ;
  finally
    strm.Free ; 
  end;
end;
end;

解决方案 »

  1.   

    试试把图片变小点再存看看:procedure TForm1.savetodbClick(Sender: TObject); 
    count
       MaxWidth=100;
       MaxHeight=100;
    var
      strm: TMemoryStream; 
      ext: String;
      widtj,height,tpint:integer;
    begin
      if image1.picture.Graphic <> nil then 
      
      begin
        if image1.width>=image1.height then
           tpint:=round(image1.width div MaxWidth)
        else 
           tpint:=round(image1.height div MaxHeight);
        width:=image1.width div tpint;
        height:=image1.height div tpint;
        image1.width:=width;
        image1.height:=height;    ext:=extractfileext(openpicturedialog1.FileName );
        strm := tmemorystream.Create ;
      try
        image1.Picture.Graphic.SaveToStream(strm);
        query1.Edit ;
        strm.Position :=0;  
        tblobfield(query1.FieldByName('photo')).LoadFromStream(strm);
        query1.Post ;
      finally
        strm.Free ; 
      end;
    end;
    end;
      

  2.   

    有没有USES JPEG?
    用image类型就可以了,不用改为binary
      

  3.   

    在BDE Admin中设置blob size和blob to cache!!