完整的代码在下面:
----------------------------------
procedure TForm1.Button1Click(Sender: TObject);
var
myFile : TFileStream;
begin
myFile := TFileStream.Create('c:/abcd.doc',fmOpenRead);
myFile.Position := 0;
ADOTable1.Edit ;
TBlobField(ADOTable1.FieldByName('aaabcd')).loadFromStream(myFile);
myFile.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
myFile : TFileStream;
begin
myFile := TFileStream.Create('c:/abcd1.doc',fmCreate);
TBlobField(ADOTable1.FieldByName('aaabcd')).SaveToStream(myFile);
myFile.Free;
end;
----------------------------------------
但此代码在编译时运行中出现可恶的提示:
Project Project1.exe raised exception class EVariantError with message 'Invalid variant type conversion'.Process stopped.UseStep or Run to continue.
不过在单独运行中,无此提示出现。
快被它烦死。