更新后刷新TClientDataset中的值

时间:2022-05-18 00:02:10

I got a TClientDataset that contains data from several tables. When I apply updates on this dataset it might get out of sync.

我有一个TClientDataset,它包含来自几个表的数据。当我对此数据集应用更新时,它可能会不同步。

I'll give you one example:

我举个例子:

In the table to update i got an id called "Client_id". The clientdataset also contains a value "Client_name" that is fetched from a "Client" table and displayed in the GUI.

在要更新的表中,我得到了一个名为“Client_id”的ID。 clientdataset还包含一个值“Client_name”,该值从“Client”表中获取并显示在GUI中。

Then I change the "Client_id" in my table and do an apply updates on the table the "Client_name" field in my dataset suddenly is out of sync. This is naturally because the clientdataset has not been refreshed.

然后我更改了表格中的“Client_id”并对表格进行了应用更新,我的数据集中的“Client_name”字段突然不同步。这很自然是因为clientdataset尚未刷新。

Now I could do a clientdataet.refresh on the afterpost event, but then the cursor on the dataset jumps to the first record, and I loose my pointer to the updated record.

现在我可以在afterpost事件上做一个clientdataet.refresh,但随后数据集上的光标跳转到第一条记录,我松开了指向更新记录的指针。

Anyone got a clue on how to solve this?

任何人都知道如何解决这个问题?

2 个解决方案

#1


0  

You should give RefreshRecord a try.

你应该试试RefreshRecord。

#2


0  

set poPropogateChanges for your provider and assign any new field values in AfterUpdateRecord event handler

为您的提供程序设置poPropogateChanges并在AfterUpdateRecord事件处理程序中分配任何新字段值

#1


0  

You should give RefreshRecord a try.

你应该试试RefreshRecord。

#2


0  

set poPropogateChanges for your provider and assign any new field values in AfterUpdateRecord event handler

为您的提供程序设置poPropogateChanges并在AfterUpdateRecord事件处理程序中分配任何新字段值