打印本文 打印本文 关闭窗口 关闭窗口
用ado 在 access 存取二进制文件的一种办法
作者:武汉SEO闵涛  文章来源:敏韬网  点击数606  更新时间:2009/4/23 10:44:21  文章录入:mintao  责任编辑:mintao

在access中建一个备注字段,名为binary。
主键id。
有一timage已装载的图片。memstream为tmemorystream;p为byte
存:

self.Image1.Picture.Bitmap.SaveToStream(memstream);

memstream.seek(0,soFromBeginning );
 while  memstream.Position<memstream.Size do
 begin
memstream.ReadBuffer(p,1);
 i:=length(inttostr(p));
self.ADODataSet1.Recordset.Fields[1].AppendChunk(inttostr(i)+inttostr(p));


 end;
self.ADODataSet1.Recordset.UpdateBatch(1);

取:
with self.ADODataSet1 do
begin

while i< recordset.Fields[1].ActualSize  do
begin

 

l:=strtoint(recordset.Fields[1].GetChunk(1));

m:=recordset.Fields[1].GetChunk(l);
i:=i+2*l+2;

try
b:=strtoint(m);
memstream.Write(b,1);
 except
 begin
 showmessage(inttostr(l));
 end;
 end;


end;
end;

      memstream.Seek(0,soFromBeginning);
 self.Image1.Picture.Bitmap.LoadFromStream(memstream);

打印本文 打印本文 关闭窗口 关闭窗口