Recent

Author Topic: [SOVED] DBGrid update data question  (Read 3276 times)

scons

  • Full Member
  • ***
  • Posts: 141
[SOVED] DBGrid update data question
« on: July 14, 2017, 04:53:15 pm »
Hi all,

I have a question I can't figure out. I would like to "upgrade" a test application I wrote a few weeks back.

I have a DBGrid, connected to an SQLite db, with a ZEOS connection.

I have set-up a few SQL commands that update other fields according to the entered data. Now I have to do the following actions to get the correct result:

  • select a field
  • edit the data (choose from a DBLookupComboBox)
  • click on the "POST" button from a DBNavigator
  • click on a "SYNC"button (which holds the various SQL commands)
  • click on the "REFRESH" button from a DBNavigator
  • now the grid is up-to-date

This is a lot of clicking one have to do. So I would like, if possible, to simplify these events.

Is it possible to do all these actions automatically ? For example, ideally this should be done automatically when leaving the edited selected field, this is option which creates the least user errors.

I tried putting the code from the "SYNC" button in the "OnEditingDone" button from the DBGrid but this seem not to have any effect.

Is it possible to simplify all this clicking ? What event should be used for this ?

Thanks
« Last Edit: July 15, 2017, 01:07:27 pm by scons »
Windows 10-64bit Lazarus 2.0.12 + FPC 3.2.0

scons

  • Full Member
  • ***
  • Posts: 141
Re: DBGrid update data question
« Reply #1 on: July 15, 2017, 01:07:11 pm »
ok found it:

after
Code: Pascal  [Select][+][-]
  1. ZQuery1.Open;

I needed to add
Code: Pascal  [Select][+][-]
  1. DataSource1.DataSet.Refresh;

Now it all works with 1 button.
Windows 10-64bit Lazarus 2.0.12 + FPC 3.2.0

 

TinyPortal © 2005-2018