D:\Users\Public\Documents\Embarcadero\Studio\16.0\Samples\Object Pascal\Database\FireDAC\Samples\Comp Layer\TFDConnection\DLL_Sharing

FDConnection1.CliHandle

FDConnection1.SharedCliHandle := ACliHandle;

CLI handle for connection sharing.

The CliHandle property returns a DBMS Call Level Interface connection handle. This value can be assigned to another TFDCustomConnection object's SharedCliHandle property. This is useful to transfer a connection from an application into a DLL. See DLL Development.

After setting Connected to True for the DLL connection, both connections will share the same physical DBMS connection. This connection must be closed after all other connections that share the same CLI handle.

CLI handle shared with other connections.

Use SharedCliHandle to set a shared DBMS Call Level Interface connection handle returned by another connection's CliHandle property. 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.

DLL Development (FireDAC)

From RAD Studio
 

Go Up to Working with Connections (FireDAC)

This topic describes how to use FireDAC in the dynamic loading libraries.

Contents

General

FireDAC may be used in a DLL as in a normal application. However, developers
must be aware of two techniques, specific to DLL development.

Connection Sharing Between an Application and a
DLL

When a connection must be transferred from an application to the DLL, the
application should not transfer the TFDCustomConnection
object, because this may lead to AV errors and other issues. This is not an
issue of FireDAC. It is due to the Delphi RTL / RTTI limitations. Note that a
connection cannot be shared with another process, because the sharing works only
inside the same address space.

To transfer a connection between an application and a DLL, the application
should transfer the TFDCustomConnection.CliHandle
property value to the DLL. Here the handle must be assigned to the TFDCustomConnection.SharedCliHandle
property.

After the TFDCustomConnection.SharedCliHandle
is assigned, the DLL connection can be activated by setting Connected to
True. Note that there is no need to set up a connection definition,
including DriverID. Then, the connection can be used as a normal database
connection. Finally, it can be closed by setting Connected to False. That
does not close the physical connection, therefore the application connection
remains active.

The application connection does not track state changes performed by the DLL.
Therefore, the DLL should preserve the same transaction state as it had before
the DLL call. It is indicated not to handle transactions in a DLL, change the
transaction isolation level and other settings in a DLL.

Also, setting SharedCliHandle does not transfer any of the option values from
an application to a DLL connection object. The DLL connection options can be set
similar to the application connection options.

For example, the DLL code:

FilreDAC DLL共享数据连接的更多相关文章

  1. 【C++】DLL内共享数据区在进程间共享数据(重要)

    因项目需要,需要在DLL中共享数据,即DLL中某一变量只执行一次,在运行DLL中其他函数时该变量值不改变:刚开始想法理解错误,搜到了DLL进程间共享数据段,后面发现直接在DLL中定义全局变量就行,当时 ...

  2. DLL入门浅析(5)——使用DLL在进程间共享数据

    转载自:http://www.cppblog.com/suiaiguo/archive/2009/07/21/90734.html 在Win16环境中,DLL的全局数据对每个载入它的进程来说都是相同的 ...

  3. #pragma data_seg() 共享数据// MyData段 // 进程 // DLL

    https://www.cnblogs.com/dongsheng/p/4476157.html http://www.cnblogs.com/CBDoctor/archive/2013/01/26/ ...

  4. 【转】VC 利用DLL共享区间在进程间共享数据及进程间广播消息

    1.http://blog.csdn.net/morewindows/article/details/6702342 在进程间共享数据有很多种方法,剪贴板,映射文件等都可以实现,这里介绍用DLL的共享 ...

  5. 使用DLL在进程间共享数据

    0x01 DLL在进程间共享数据理论 1.可以在Dll中使用#pragma data_seg建立共享类型的数据段将需要共享的数据分离出来,放置在一个独立的数据段里,并把该段的属性设置为共享,从而实现不 ...

  6. #pragma data_seg 共享数据区(转)

    原文地址:http://www.cnblogs.com/CBDoctor/archive/2013/01/26/2878201.html 1)#pragma data_seg()一般用于DLL中.也就 ...

  7. 详解 Qt 线程间共享数据(用信号槽方式)

    使用共享内存.即使用一个两个线程都能够共享的变量(如全局变量),这样两个线程都能够访问和修改该变量,从而达到共享数据的目的. Qt 线程间共享数据是本文介绍的内容,多的不说,先来啃内容.Qt线程间共享 ...

  8. VC++共享数据段实现进程之间共享数据

    当我写了一个程序,我希望当这个程序同时运行两遍的时候,两个进程之间能共享一些全局变量,怎么办呢?很简单,使用VC\VC++的共享数据段.; #pragma data_seg()//恢复到正常段继续编程 ...

  9. Qt学习:线程间共享数据(使用信号槽传递数据,必须提前使用qRegisterMetaType来注册参数的类型)

    Qt线程间共享数据主要有两种方式: 使用共享内存.即使用一个两个线程都能够共享的变量(如全局变量),这样两个线程都能够访问和修改该变量,从而达到共享数据的目的: 使用singal/slot机制,把数据 ...

随机推荐

  1. 现在很火的数据科学到底是什么?你对做DATA SCIENTIST感兴趣吗?

    转自– Warald (Email: iamxiaoning@gmail.com) 博客: http://www.1point3acres.com,微博:http://www.weibo.com/wa ...

  2. 快速排序的partition版本实现

    int partition(int arr[], int low, int high) { int pivot = arr[high]; int i = low-1; for (int j = low ...

  3. selenium-java,解决一些加了显性等待和隐性等待都不好使的情况,以及给UI自动化加上暂停功能

    最近在UI自动化时遇到了,上一步成功操作后没有响应的情况(动画加载和浏览器加载导致实际没有问题),导致下一步无法成功操作,所有想在尝试2次操作后再次进行上一步操作解决这种情况导致的错误(其实是不想每一 ...

  4. 《selenium2 python 自动化测试实战》(7)——定位一组对象

    定位一组对象 定位一组对象——find_elements_by_...(),注意,这里是elements,复数.返回的结果是一个列表,我们取值的时候就要用列表取值的方式来获得自己想要的元素.需要注意的 ...

  5. 电源lc滤波及单点接地(转载)

    1.在一个高速数字电路设计里面,看到在电源部分进行了如下的处理.不过怎么都不能理解,如果说1uF和0.1uF电容并联,这块处理是一个经验值.那么前面的LC滤波参数,参数又是如何确定的?DVDD-in输 ...

  6. FastAdmin 的 API 可以分级吗?

    FastAdmin 的 API 可以分级吗? 有小伙伴问 FastAdmin 的API 可以分别吗,使用 / 出现错误. Karson 的说明是: 完全支持的,默认是使用.进行分隔的,如果需要/,请开 ...

  7. Web 漏洞分析与防御之 CSRF(二)

    原文地址:Web 漏洞分析与防御之 CSRF(二) 博客地址:http://www.extlight.com 一.全称 跨站请求伪造(Cross-site Request Forgery) 二.原理 ...

  8. STL容器的resize方法

    刚才写DFS程序,为了加个创建DFS树然后再次遍历的功能,把初始化的代码给封装到init()函数里,然后直接调用之后对同样是邻接表表示的DFS树进行DFS. 然后令人诧异的是竟然没有打印结果,调试发现 ...

  9. Java-Runoob-高级教程:Java Applet 基础

    ylbtech-Java-Runoob-高级教程:Java Applet 基础 1.返回顶部 1. Java Applet 基础 Applet 是一种 Java 程序.它一般运行在支持 Java 的 ...

  10. C++Windows核心编程读书笔记

    转自:http://www.makaidong.com/%E5%8D%9A%E5%AE%A2%E5%9B%AD%E6%96%87/71405.shtml "C++Windows核心编程读书笔 ...