Recent

Author Topic: TDBGrid refresh problem  (Read 2328 times)

ronhud

  • Jr. Member
  • **
  • Posts: 84
TDBGrid refresh problem
« on: April 13, 2018, 01:19:24 pm »
I am struggling with getting a dbgrid to update at runtime.
I have a TDBGrid connected to a IBConnection (Firebird) and am using aTDataSource, TSQLTransaction and TSQLQuery.
I have made a simple app - the above with a TTimer.  When the app starts it displays the records correctly.  When the OnTimer event is called I have the following code which is described in several searches I have made as all that is necessary to get the grid to update.

DBGrid1.DataSource.DataSet.Refresh;

I use Robin to manually change a field in the table being displayed but when the next OnTimer event happens the data shown in the grid has not changed.

Any help please?



« Last Edit: April 13, 2018, 01:22:52 pm by ronhud »

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: TDBGrid refresh problem
« Reply #1 on: April 14, 2018, 05:12:07 pm »
Have you tried DBgrid1.Invalidate ?

 I wanted to add that you may also need to call the commit or close and re-open..

 I don't do a lot of db stuff but I do know the engine does not do an update right away, you need to
force it..
« Last Edit: April 14, 2018, 06:49:08 pm by jamie »
The only true wisdom is knowing you know nothing


rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: TDBGrid refresh problem
« Reply #3 on: April 14, 2018, 07:57:32 pm »
Yes, it's due to the isolation level.

This is a duplicate post.
The original is here
https://forum.lazarus.freepascal.org/index.php/topic,40899

I explained that the default level is SNAPSHOT. So if you don't specify the isolation level you get a SNAPSHOT. You need to set it at READ_COMMITED to be able to read the commited data from other transaction (or you need to close the transaction so it opens a new one with the next open).

 

TinyPortal © 2005-2018