com+中使用 TADOConnection与olevariant如何相互, (200分)

  • 主题发起人 主题发起人 yanlei
  • 开始时间 开始时间
Y

yanlei

Unregistered / Unconfirmed
GUEST, unregistred user!
com+中使用 将]TADOConnection相互为olevariant,
 
var
ac: TADOConnection;
o: OleVariant;
begin
o := OleVariant(ac);
 
老大[Error] connoraPas.pas(134): Invalid typecast
 
将TADOConnection,存成流然后转换在OleVariant
 
到此一游
 
具体怎么做
 
var
ConStream: TMemoryStream;
A: TADOConnection;
P: Pointer;
C: Olevariant;
begin
ConStream:= TMemoryStream.Create ;
try
conStream.WriteComponent(A);
p := VarArrayLock(C);
conStream.Position := 0;
//start from begin
ning of stream
conStream.Read(p^, conStream.Size);
finally
VarArrayUnlock(C);
FileStream.Free;
end;
end;

没调试过,太概就这样吧!
 
接受答案了.
 
后退
顶部