关于保存OLE对象到数据库(100分)

  • 主题发起人 主题发起人 szgh
  • 开始时间 开始时间
S

szgh

Unregistered / Unconfirmed
GUEST, unregistred user!
我从TOLEContainer类派生一个新类TMycontainer,并重写Change方法:
procedure Changed; override;
想依次来保存OLE对象到数据库,可总是提示错误:
"调用者正在执行异步调用,无法生成代表此调用的外部调用",请大家帮帮我.代码如下:

TUseOleContainer = Class(TOleContainer)
private
FOnDataChange: TDataChange;
protected
procedure Changed; override;
published
property OnDataChange: TDataChange read FOnDataChange write FOnDataChange;
end;
...

procedure TfrmTemplate.mObjectClick(Sender: TObject);
var
BlobStream: TADOBlobStream;
begin
with DMDMain.ADODataSetItem do
OleObj.OnDataChange := nil;
BlobStream := TADOBlobStream.Create(TBlobField(FieldByName('Objects')),bmRead);
OleObj.LoadFromStream(BlobStream);
oleobj.DoVerb(ovOpen);
OleObj.OnDataChange := OleDataChange;
end;

procedure TfrmTemplate.OleDataChange;
var
BlobStream: TADOBlobStream;
begin
//对象被修改
with DMDMain.ADODataSetItem do begin
edit;
BlobStream := TADOBlobStream.Create(TBlobField(FieldByName('Objects')),bmWrite);
OleObj.SaveToStream(BlobStream);
BlobStream.Free;
Post;
end;
end;
 
接受答案了.
 
后退
顶部