Page 1 of 1

How to change values of a mysql database via dbgrid?

Posted: Tue 23 Apr 2013 09:48
by Robin2k
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;

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

Posted: Wed 24 Apr 2013 13:16
by DemetrionQ
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.