Forum > Databases
TDBGrid refresh problem
ronhud:
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?
balazsszekely:
Just Close and Open the dataset and you're good to go.
ronhud:
thanks but that did not work. Is anything special required when the changes to the database are being made by a seperate program - Robin in this case
balazsszekely:
Make sure you commit the transaction on the other side(Robin in this case).
ronhud:
Yes the changes in Robin are committed and I check the table after the change also. Here is the code:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, IBConnection, sqldb, db, FileUtil, Forms, Controls, Graphics, Dialogs, DBGrids, ExtCtrls; type { TForm1 } TForm1 = class(TForm) DataSource1: TDataSource; DBGrid1: TDBGrid; IBConnection1: TIBConnection; Panel1: TPanel; SQLQuery1: TSQLQuery; SQLTransaction1: TSQLTransaction; Timer1: TTimer; procedure Timer1Timer(Sender: TObject); private public end; var Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Timer1Timer(Sender: TObject);begin SQLQuery1.Close; SQLQuery1.Open; Panel1.Caption := 'last timer ' + DateTimeToStr(Now);end; end.
Navigation
[0] Message Index
[#] Next page