I'm using Delphi XE3 with a MySQL database. I have a SQLconnection – SQLquery – DataSetProvider – ClientDataSet arrangement. When I ApplyUpdates of a modification to the CDS, the change is affected in the database correctly but when I Refresh the CDS, the "old" values are replaced. The code I'm using is:
CDS.IndexFieldNames:='pop0';
CDS.first;
for W := 1 to 5 do begin // display the original data
memo2.lines.add (IntToStr(CDS['pop0'])); CDS.Next;
end;
memo2.lines.add('');
CDS.first;
CDS.Edit; // modify data
CDS['pop0']:= 3004;
CDS.Post;
CDS.first;
for W := 1 to 5 do begin // display the modified data
memo2.lines.add (IntToStr(CDS['pop0'])); CDS.Next;
end;
memo2.lines.add('');
CDS.ApplyUpdates(0) ;
messagedlg('Check database',mtInformation,[mbOK],0);
CDS.refresh;
CDS.first;
for W := 1 to 5 do begin // display the updated data
memo2.lines.add (IntToStr(CDS['pop0'])); CDS.Next;
end;
the output in the memo is as follows:
3
4
375
597
678
4
375
597
678
986
3
4
375
597
678
I have tried to close and open the CDS as an alternative for refresh but I got the same result. Any ideas why this is happening?