TmyTable.Post visibility after updating a record

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
mjbcomp
Posts: 3
Joined: Wed 14 Apr 2021 03:45

TmyTable.Post visibility after updating a record

Post by mjbcomp » Thu 20 May 2021 02:58

I have a simple TmyTable component on a form connected to a Connection component connected to a MySQL table.

i have logged into the form from two different computers. When the form opens the first thing it does it opens the table like this:

MyTable.Open;

The form has one field called 'Amount'. When the user clicks the Edit button, it performs a TmyTable.Edit. The user types in whatever value they want in the amount field then they click the Save button which performs a TmyTable.Post.

Here's the problem:

When i click the Edit button on the same record on the second computer i don't see the changes. I see the default value.
The only way to get the second computer to see the changes made on the first computer is to to call MyTable.Refresh before calling MyTable.Edit.

the TMyTable is using all default values:
FetchAll = TRUE
LockMode = lmNone

Is this the expected behavior? Are there any settings i need to modify on the TmyTable component to ensure that when you call .Post that it updates/refreshes the underlying table so the next user will see the changes?

Should i set the RefreshOptions.roBeforeEdit = TRUE? Would that solve the problem? and is that the most efficient way to do it?

PS: i have already asked this question on the MySQL forum and they referred me here.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: TmyTable.Post visibility after updating a record

Post by ViktorV » Thu 20 May 2021 10:16

Hey,

Please note that MySQL does not have the option to receive info about changes made in another request without server request. In order to get actual data, you should call the Refresh method.
You also did a great job while solving your task by setting up RefreshOptions.roBeforeEdit option to True:
https://www.devart.com/mydac/docs/devar ... tions.htm

Best regards,
Viktor

Post Reply