How to change values of a mysql database via dbgrid?

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Robin2k
Posts: 1
Joined: Tue 23 Apr 2013 09:47

How to change values of a mysql database via dbgrid?

Post by Robin2k » Tue 23 Apr 2013 09:48

Hey guys good morning,

i got a DBGrid and the UniDac components. I a use a popupmenu and select a row. I fill via the onclick event from the popupmenu a new form with my data in my TEdit.

Now the problem is, that i want to edit my data which i selected from the dbgrid.

This code works until dbgrid is refreshed and then the old values are back again in my dbgrid. How can i change it for the mysql table too not only for the dbgrid?

My actually Code

Code: Select all

FQuery.Edit;
   FQuery.FieldByName('CfgUID').AsString := Edit4.Text;
   FQuery.FieldByName('CfgMod').AsString := Edit1.Text;
   FQuery.Post;

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: How to change values of a mysql database via dbgrid?

Post by DemetrionQ » Wed 24 Apr 2013 13:16

Hello.

You have probably set the TUniQuery.CachedUpdates property to True. In this case, all changes are sent to the server only after calling the TUniQuery.ApplyUpdates method. To solve the problem, either set the TUniQuery.CachedUpdates property to False, or use the TUniQuery.ApplyUpdates method in the following way:

Code: Select all

   FQuery.Edit;
   FQuery.FieldByName('CfgUID').AsString := Edit4.Text;
   FQuery.FieldByName('CfgMod').AsString := Edit1.Text;
   FQuery.Post;
   FQuery.ApplyUpdates;
The detail information about CachedUpdates property and ApplyUpdates method can be seen in the UniDAC documentation.

Post Reply