We would like to share ADOConnection across the DLL boundary (Delphi in Delphi at the moment, although there may also be C # for Delphi in the near future).
As we would like to flexibly call DLLs from C # in the future, we hoped that we could define a DLL call using _Connection as a parameter. Sort of:
procedure DoStuff (ADOConnection: _Connection)
var
InnerConnection: TADOConnection;
begin
InnerConnection := TADOConnection.create(nil);
try
InnerConnection.ConnectionObject := ADOConnection;
DoMoreStuff(InnerConnection);
finally
InnerConnection.free;
end;
end;
Unfortunately, the TADOConnection destructor code closes the connection passed to it, which is an undesirable side effect. Adding
InnerConnection.ConnectionObject := nil
before free does nothing as it falls on
if Assigned(Value) = nil
in TADOConnection.SetConnectionObject, which causes the call to do nothing.
? , , . TADOConnection - , .
: / TADOConnection .Open, ( , , , " " MS UDL)