[英]Master/Detail DataSnap via FireDac and MySql ¿Why data written into a detail record in one client is not seen from a second client?
I have a DataSnap Server
with two TFDQuery's
via TFDConnection
to a MySQL
database. 我有一个
DataSnap Server
有两个TFDQuery's
通过TFDConnection
到MySQL
数据库。 This querys are in a master/detail relationship
via a TDataSource
(neested datasets). 此查询通过
TDataSource
(必需的数据集)处于master/detail relationship
。 This data is exported via one TDataSetProvider
. 此数据通过一个
TDataSetProvider
导出。
In the client side, I have a TDataModule
with one TSQLConnection
, one TDSProviderConnection
and two TClientDataSet's
, one for the Master
and the other for the Neested Detail
via DataSetField
property. 在客户端,我有一个
TDataModule
一个TSQLConnection
,一个TDSProviderConnection
和两个TClientDataSet's
,一个是Master
,另一个为Neested Detail
通过DataSetField
财产。
When i test my client everything works fine. 当我测试客户时,一切正常。
The problem is when two clients
are working simultaneously
over the same detail record , the data I write to one Detail in one Client is not seen from my second Client, and vice versa. 问题是当
two clients
simultaneously
在同一个明细记录上工作simultaneously
,从我的第二个客户中看不到我写入一个客户中的一个明细中的数据,反之亦然。
Suppose we have this scenario with a simple bill/items relationship: Bill1, Item1, OriginalData 假设我们有一个简单的Bill / item关系的场景: Bill1,Item1,OriginData
if i read Bill1 in both clients, both read the same data. 如果我在两个客户端中均读取Bill1 ,则两者都读取相同的数据。 If i modify the OriginalData to ModifiedData in my First Client, and execute
ApplyUpdates
, it works fine, but then i refresh the same Bill1 in my second Client, and still reading the unchanged OriginalData 如果我在第一个客户端中将OriginalData修改为ModifiedData并执行
ApplyUpdates
,则可以正常工作,但是随后我在第二个客户端中刷新了相同的Bill1 ,并且仍在读取未更改的OriginalData
If I write data into the MasterTable
everything works fine, buy with my DetailTable
it seems to get data from some cache or something. 如果我将数据写入
MasterTable
一切正常,请与我的DetailTable
一起购买,似乎是从某些缓存或其他内容中获取数据。 I reproduce all via BDE
components and Paradox
database and have no problems, but we need to use FireDac
and MySQL
我通过
BDE
组件和Paradox
数据库复制了所有文件,没有问题,但是我们需要使用FireDac
和MySQL
So, here is the question... ¿Why the data written to detail record in the first client is not seen from my second client after calling refresh with DataSnap
via FireDac
and MySql
? 因此,这是一个问题……为什么在通过
FireDac
和MySql
使用DataSnap
调用refresh之后,从第二个客户端看不到写入第一个客户端的详细记录的数据?
I'm using Delphi Xe5 update 2. 我正在使用Delphi Xe5 Update 2。
Note: The Master/Detail
is a parametrized Query
, so only one Bill is active at a time. 注意:“
Master/Detail
是parametrized Query
,因此一次仅激活一个Bill。
Once again, sorry for my poor english. 再次抱歉我的英语不好。
Solved it by setting FetchOptions.DetailOptimize=FALSE
of the TFDConnection
on the server side. 通过在服务器端设置
TFDConnection
FetchOptions.DetailOptimize=FALSE
来解决此问题。
When DetailOptimize is true (default on FireDac) FireDac refresh the detail dataset only when the current detail dataset key field values are different from the master dataset key field values. 当DetailOptimize为true(FireDac上的默认设置)时,FireDac仅在当前详细信息数据集关键字段值与主数据集关键字段值不同时刷新详细信息数据集。
For more info read FireDAC.Stan.Option.TFDFetchOptions.DetailOptimize 有关更多信息,请阅读FireDAC.Stan.Option.TFDFetchOptions.DetailOptimize
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.