Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TFDQuery Not Posting data To database



Permlink Replies: 2 - Last Post: May 6, 2016 9:24 AM Last Post By: Lajos Juhasz
Vishal Tiwari

Posts: 10
Registered: 3/27/10
TFDQuery Not Posting data To database
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 5, 2016 11:06 PM
Hi,

I have TFDQuery with below properties enebled:
CashedUpdates = True;
UpdateOptions.uvUpdateMode = True;
RequestLive = True;
TableName = 'MyTable';

This query component is connected to DataSource and This dataa source is connected to DBGrid and DBNavigator.

But when I click on Post button in DBNavigator data doesn't post to the database.

Any idea why?

Regards.
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: TFDQuery Not Posting data To database
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 6, 2016 9:00 AM   in response to: Vishal Tiwari in response to: Vishal Tiwari
Vishal Tiwari wrote:
Hi,

I have TFDQuery with below properties enebled:
CashedUpdates = True;
UpdateOptions.uvUpdateMode = True;
RequestLive = True;
TableName = 'MyTable';

This query component is connected to DataSource and This dataa source is connected to DBGrid and DBNavigator.

But when I click on Post button in DBNavigator data doesn't post to the database.

Any idea why?

Regards.

Because you are caching the updates. If you want changes to go immediately to
the DB that should be false. With it true you have to call ApplyUpdates (I
believe) like you would with a ClientDataset.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: TFDQuery Not Posting data To database
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 6, 2016 9:24 AM   in response to: Vishal Tiwari in response to: Vishal Tiwari
Vishal Tiwari wrote:

Hi,

I have TFDQuery with below properties enebled:
CashedUpdates = True;
UpdateOptions.uvUpdateMode = True;
RequestLive = True;
TableName = 'MyTable';

This query component is connected to DataSource and This dataa source
is connected to DBGrid and DBNavigator.

But when I click on Post button in DBNavigator data doesn't post to
the database.

Any idea why?
The reason is very simple in cachedUpdates modes the changes are cached
and are written by executing ApplyUpdates. You can try this by enabling
the ApplyUpdates button on the DBNavigator. Or you can try by adding
the following event":

procedure TForm2.DBNavigator1Click(Sender: TObject; Button:
TNavigateBtn);
begin
  if button=nbPost then
  begin
    TFDQuery(TDBNavigator(sender).DataSource.DataSet).ApplyUpdates;
    TFDQuery(TDBNavigator(sender).DataSource.DataSet).CommitUpdates;
  end;
end;

PS. I never used DBNavigator so this is based on the help

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02