S
suninrain
Unregistered / Unconfirmed
GUEST, unregistred user!
用下面的代码可以实现从数据库里提取已经保存的EXCEL文件,并放到已经打开的OleContainer 里,但是多次操作后,会出现“被调用的对象已与其客户端断开连接”的错误,或者“不支持该借口”的错误,而且用TRY EXCEPT也捕捉不到该错误,有那位朋友知道怎么解决该问题啊?
先出100分,问题解决后再出200分
var ms:TmemoryStream;
begin
with dm1.adoquery1 do
begin
close;
sql.text:='select * from excel where id=1';
open;
end;
ms:=TmemoryStream.Create;
TBlobField(dm1.adoquery1.FieldByName('excel')).SaveToStream(ms);
ms.Position:=0;
try
OleContainer1.LoadFromStream(ms);
OleContainer1.Run;
while not (OleContainer1.State in [osRunning]) do
sleep(200);
OleContainer1.DoVerb(ovshow);
finally
ms.Free;
end;
先出100分,问题解决后再出200分
var ms:TmemoryStream;
begin
with dm1.adoquery1 do
begin
close;
sql.text:='select * from excel where id=1';
open;
end;
ms:=TmemoryStream.Create;
TBlobField(dm1.adoquery1.FieldByName('excel')).SaveToStream(ms);
ms.Position:=0;
try
OleContainer1.LoadFromStream(ms);
OleContainer1.Run;
while not (OleContainer1.State in [osRunning]) do
sleep(200);
OleContainer1.DoVerb(ovshow);
finally
ms.Free;
end;