怎样在access中存取图片的路径,再用代码读出,用dbimage显示出来。
我需要详细点的代码!
我还在做毕业设计

解决方案 »

  1.   


    uses jpeg;
    .......var v_path:string;
        v_photo:TJPEGImage;
    begin
      v_path:='路徑';
      v_photo:=TJPEGImage.Create;
      v_photo.LoadFromFile(v_path);
      table1.edit;
      table1.FieldByName('path').Value:=v_path;//path為路徑字段
      table1.FieldByName('photo').Assign(v_photo);//photo為圖片字段
      table1.Post;
    end;
    給你點思路
      

  2.   

    为什么你的数据库中还有图片字段呢
    我得意思只存路径,通过dbimage读取
      

  3.   

    var v_photo:TJPEGImage;
    begin
      v_path:=table1.FieldByName('path').Value;
      v_photo:=TJPEGImage.Create;
      v_photo.LoadFromFile(v_path);
      DBImage1.Picture.Assign(v_photo);
    end;
      

  4.   

    TO 小别:按照你的方法根本不能向数据库中存取图片,向数据库中写数据的时候说“Bitmap is 
    not valid”,是不是一顶要把图片先转换成BMP格式才能向数据库中存取了,还有其他的方法吗?
      

  5.   

    1. btnSave的Click事件,这里演示了TMemoryStream的另一种用法,将Stream中的数据写到数据库中去。 var
     MS: TMemoryStream;
    begin
     MS:=TMemoryStream.create;
     Image1.Picture.Bitmap.SaveToStream(MS);
     MS.Position:=0;
     Table1.Append;  
    file://在数据库中添加一条记录
     TBlobField(Table1.FieldbyName
    ('image')).LoadFromStream(MS);
     Table1.Post;    
    file://将所作的更新写入数据库
    end;
    上面是用blob类型(二进制流)的字段向数据库中存图片。
    将dbimage的datasource设置好后, 将datafield设为image就可以了, 只是个例子,应该能有点帮助。