Watch, Follow, &
Connect with Us

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


Welcome, Guest
Guest Settings
Help

Thread: Editing from a dbGrid?


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 5 - Last Post: Mar 13, 2017 9:41 PM Last Post By: Dmitry Arefiev
Chris LeFebvre

Posts: 65
Registered: 10/24/99
Editing from a dbGrid?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 12, 2017 8:12 PM
I'm trying to edit the results of a query in a dbgird, I have a TFDQuery, TFDTransaction, TDatasource, TFDUpdateSQL and a TRzDbgrid (Raize dbgrid); the TFDQuery is set to use Cached updates, also under update options ReadOnly is set to false; the query's updateobject is properly set to the TFDUpdateSQL component and the TFDUpdateSQL component has had the proper Sql generated.

As far as I can tell everything is properly set and this should work, is there anything else I should check?

Thanks!
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Editing from a dbGrid?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 13, 2017 12:04 AM   in response to: Chris LeFebvre in response to: Chris LeFebvre
Looks correct. But what is the problem ? Or you just need a confirmation that you are on the right way ?

--
With best regards,
Dmitry
Chris LeFebvre

Posts: 65
Registered: 10/24/99
Re: Editing from a dbGrid?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 13, 2017 7:16 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Dmitry Arefiev wrote:
Looks correct. But what is the problem ? Or you just need a confirmation that you are on the right way ?

--
With best regards,
Dmitry

Sorry, the problem is that when I edit data in the dbgrid and change rows or close the query and then check the data the changes I've made haven't been saved and no error is generated.
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Editing from a dbGrid?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 13, 2017 7:17 AM   in response to: Chris LeFebvre in response to: Chris LeFebvre
http://docwiki.embarcadero.com/RADStudio/Berlin/en/Caching_Updates_(FireDAC)#Applying_Updates

--
With best regards,
Dmitry
Chris LeFebvre

Posts: 65
Registered: 10/24/99
Re: Editing from a dbGrid?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 13, 2017 6:37 PM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Dmitry Arefiev wrote:
http://docwiki.embarcadero.com/RADStudio/Berlin/en/Caching_Updates_(FireDAC)#Applying_Updates

--
With best regards,
Dmitry

Got it, I added this to the BeforeScroll event and it appears to be working:
  If qMyData.State = dsEdit Then
   Begin
     qMyData.ApplyUpdates;
     qMyData.CommitUpdates;
     If trMyData.Active Then trPianos.Commit;
   End;


As always thanks for your help!
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Editing from a dbGrid?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 13, 2017 9:41 PM   in response to: Chris LeFebvre in response to: Chris LeFebvre
Got it, I added this to the BeforeScroll event and it appears to be working:

If you going to post changes to the database after each Edit / Post, then you does not need to set CachedUpdates=True.
Just leave it False. FireDAC will use TFDUpdateSQL in any case, if you care about that.

--
With best regards,
Dmitry
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02