FireDAC.Comp.Client.TFDCustomConnection.SharedCliHandle

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

property SharedCliHandle: Pointer read FSharedCliHandle write SetSharedCliHandle;

C++

__property void * SharedCliHandle = {read=FSharedCliHandle, write=SetSharedCliHandle};

Properties

Type Visibility Source Unit Parent
property public
FireDAC.Comp.Client.pas
FireDAC.Comp.Client.hpp
FireDAC.Comp.Client TFDCustomConnection

Description

CLI handle shared with other connections.

Use SharedCliHandle to set a shared DBMS Call Level Interface connection handle returned by another CliHandle property of a connection. This is useful to transfer the connection from an application into a DLL (see DLL Development).

Note: A connection cannot be shared with another process, as the sharing works only inside the same address space.

After setting Connected to True for this connection, it will use the same physical DBMS connection or session as the other connection, and it will share the same transaction state. 

After setting Connected to False, this DLL connection will not release the connection resources to the DBMC client. The application connection is responsible for resources releasing. Because of that, the application connection must be closed after closing all the sharing connections.

Example

//Application code (without checks):
  FhDll := LoadLibrary(PChar('Project2.dll'));
  @FpShowData := GetProcAddress(FhDll, PChar('ShowData'));
  FpShowData(FDConnection1.CliHandle);

//DLL code:
procedure ShowData(ACliHandle: LongWord);
begin
  FDConnection1.SharedCliHandle := ACliHandle;
  FDConnection1.Connected := True;
  FDQuery1.Active := True;
end;

See Also