Author: Tomas Rutkauskas
I am using a TDBGrid through a slow ODBC connection to the data. When I scroll the
grid it changes the selected row and takes an age to update all the "detail"
queries run off it. The time it takes to update the "detail" queries wouldn't be a
problem if I could scroll the grid and then select a new row once the one I want
was in view. Any ideas?
Answer:
Don't use automatic linking, because it re-executes detail queries on every
datachange. Instead, use manual linking with timer:
1 procedure Datasource1Datachange(...)
2 begin3 Timer1.Enabled := false;
4 Timer1.Enabled := true;
5 end;
6 7 8 procedure Timer1Timer(..);
9 begin10 {details will be refreshed only when timer expires}11 DetailQ.Params[0].AsInteger := MasterQLinkField.AsInteger;
12 DetailQ.Close;
13 DetailQ.Open;
14 end;
I use timer interval from 300 - 500 ms. With this small trick you'll see a real performance boost.