保持到数据库中已经用下面的代码解决
        TmpImage := TMemoryStream.Create;
        TmpJpg := TJPEGImage.Create;
        TmpJpg.LoadFromFile(OpenDialog1.FileName);
        TmpJpg.SaveToStream(TmpImage);
        TmpImage.Position :=0;
        Sqlquery1.ParamByName('photo').LoadFromStream(TmpImage,ftBlob);
        TmpImage.Free ;
        TmpJpg.Free;
读取并显示该如何做?

解决方案 »

  1.   

    图片是JPEG格式的
    用这个提示“bitmap image not valid”  s:=Sqlquery1.CreateBlobStream(sqlQuery1.FieldByName('photo'),bmRead);
      Image1.Picture.Bitmap.LoadFromStream(s);
      s.Free;
      

  2.   


    uses jpeg;
    保存Image1中的图象至数据库 :
    var 
      Ms:TmemoryStream;
      jpg:Tjpegimage;
    begin
      ms:=TmemoryStream.Create;
      Jpg.Assign(Image1.Picture.Graphic);
      Jpg.SaveToStream(Ms) ;
      Ms.Position :=0;
      ADOquery1.append;
      TBlobField(ADOquery1.FieldByName('img')).LoadFromStream(Ms);
      ADOquery1.Post;
      Ms.Free ;
      jpg.free;
    end;
    从数据库中读取图象到image2中:
    Var
      Ms:TStringStream;
      jpg:Tjpegimage;
    begin
      Ms:=TstringStream.Create('');
      TBlobField(ADOquery1.FieldByName('img')).SaveToStream(Ms);
      Ms.Position :=0;
      Jpg.LoadFromStream(Ms);
      Image2.Picture.Assign(Jpg);
      Ms.Free;
      jpg.free;
    end;///  
      

  3.   

    To spsonic:图片是JPEG格式的
    用这个提示“bitmap image not valid”  s:=Sqlquery1.CreateBlobStream(sqlQuery1.FieldByName('photo'),bmRead);
      Image1.Picture.Bitmap.LoadFromStream(s);
      s.Free;
    你的代码改为:
      s:=Sqlquery1.CreateBlobStream(sqlQuery1.FieldByName('photo'),bmRead);
      Image1.Picture.LoadFromStream(s);
      s.Free;
    就可以了,就不会报错了。
      

  4.   

    to gxgyj(杰克.逊)
    一定要使用ADOquery吗?to Gui_yun(乘风)
    Image1.Picture没有LoadFromStream()啊
      

  5.   

    不是吧?Delphi帮助文件(Delphi6)里明明写着的:In TPictureAssign
    Create
    Destroy
    LoadFromClipboardFormat
    LoadFromFile
    RegisterClipboardFormat
    RegisterFileFormat
    RegisterFileFormatRes
    SaveToClipboardFormat
    SaveToFile
    SupportsClipboardFormat
    UnregisterGraphicClass
      

  6.   

    呵呵,看错了,存成临时文件然后Load那个文件
      

  7.   

    如果是bmp格式的图象就简单多了
    with adoquery1 do
    begin
      sql.clear;
      sql.add('select * from table where name=:'+edit1.text);
      open;
      Image1.Picture.Bitmap.Assign(FieldByName('photo'));//加载数据库中查找出来的图片到image中
      .
      .
      .
    end;