同志们,有木有碰到这类的问题的?用的 access数据表
var Form1: TForm1;
ms,zhongjianbianliang,f1,f2:TmemoryStream;
i,wenjianwei:integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
ms:= TMemoryStream.Create;
zhongjianbianliang:= TMemoryStream.Create;
ms.LoadFromFile('lz.doc');
ms.Seek(0,2);
wenjianwei:=ms.Position;
ms.seek(0,0);
while ms.Position<wenjianwei do
begin
zhongjianbianliang.CopyFrom(ms,1);
end;
adotable1.edit;
adotable1.append;
tblobfield(adotable1.FieldByName('timu')).LoadFromStream(zhongjianbianliang);
adotable1.post;
ms.Free;
zhongjianbianliang.free;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
f1:= TmemoryStream.Create;
f2:= TMemoryStream.Create;
adotable1.first;
for i:=1 to adotable1.RecordCount do
begin
TBlobField(ADOTable1.FieldByName('timu')).SaveToStream(f1);
f2.copyfrom(f1,0);
f1.Clear;
adotable1.Next;
end;
f2.SaveToFile('ls.doc');
f1.Free;
end;
end.
操作:Button1Click点两次,将lz.doc内容存入"timu"字段,生成两条相同内容的记录;点Button2Click,输出ls.doc
问题:ls.doc内容应是lz.doc的重复,为什么两者内容一样,只不过ls.doc约lz.doc两倍大小?