Direct Grid Update How To Do It

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
gohjoe
Posts: 7
Joined: Thu 17 Jan 2008 14:35

Direct Grid Update How To Do It

Post by gohjoe » Thu 10 Apr 2008 15:46

How to do a direct grid update? I place a dbgrid on a form, connecting to a MyQuery1 or MyTable1? I next place a save button. What is the simplest way to update the changes I make in the grid to the data? What are the commands neccesary to make this happen. My current tries result in O records found - failed.

I used the following:
MyQuery.CachUpdate := True;
MyQuery.ApplyUpdates;
MyQuery.CommitUpdates;

Pls Advise
Blurr NewBie :)

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 11 Apr 2008 12:37

You should set the CachedUpdates property to True before making any changes.
After changing data call

Code: Select all

  MyQuery.ApplyUpdates;
  MyQuery.CommitUpdates;
to save the changes to the database.

gohjoe
Posts: 7
Joined: Thu 17 Jan 2008 14:35

Not Working!

Post by gohjoe » Mon 14 Apr 2008 12:48

Yap! I did that. But the message came out that "0 record found. Update Failed". I turned of StrictUpdate to False to prevent this message but on refresh, the previous data return. I know you have written on this in FAQ but only solution to LIVE UPDATE has not been given. In Access, I believe there is a REQUESTLIVE option. Is it possible in Delphi with MyDac. Is there a shorter example than the included example? This question has been raised before in this forum, but I have yet to locate an adequate solution. Can you help?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 15 Apr 2008 07:15

For these records to be changed correctly, there should be key fields in the table.
You can see how to work with CachedUpdates in the CachedUpdates demo of MyDacDemo.

Post Reply