Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-12

DBGrid / DBNavigator not refreshing

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Chris Jennings

Hi All

When I fill in field values in a series of DBEdits and then click on the Post button of my DBNav the record is inserted in my DB as expected. My problem is that a DBgrid attached to the process does not referesh properley. It does display the addition but does so at the point in the grid where the cursor last resided.

I would like to see the DBGrid refresh such that the record followed the mySQL indexing structure and displayed the new entry in alphabetical order for one of the fileds.

As an example the grid will show

AAA
BBB
ZZZ
CCC after an insert when it should show

AAA
BBB
CCC
ZZZ

Any ideas would be appreciated.

Thanks

Chris

Reply by email

JoshyFun
to Chris Jennings

Hello Lazarus-List,

Sunday, December 6, 2009, 7:24:37 PM, you wrote:

CJ> I would like to see the DBGrid refresh such that the record followed the CJ> mySQL indexing structure and displayed the new entry in alphabetical CJ> order for one of the fileds.
From my point of view you must post, commit and reissue the query, once the query is finished you can traverse it looking for your inserted field and move the DB cursor to that point. You can disable controls while fetching and exploring the table to avoid visual non desirable flashes.

Best regards, JoshyFun

Reply by email

Chris Jennings
to JoshyFun

Thanks JoshyFun

procedure TfrmSubjects.zqrySubjectsAfterPost(DataSet: TDataSet);
begin
  zqrySubjects.Close;
  zqrySubjects.Open;
end;

did the trick

cj

JoshyFun wrote 15 lines
Hello Lazarus-List, Sunday, December 6, 2009, 7:24:37 PM, you wrote: CJ> I would like to see the DBGrid refresh such that the record followed the CJ> mySQL indexing structure and displayed the new entry in alphabetical CJ> order for one of the fileds. >From my point of view you must post, commit and reissue the query, once the query is finished you can traverse it looking for your inserted field and move the DB cursor to that point. You can disable controls while fetching and exploring the table to avoid visual non desirable flashes.

Reply by email

Luca Olivetti
to Chris Jennings

En/na Chris Jennings ha escrit:

Show quoted text 9 lines
Thanks JoshyFun procedure TfrmSubjects.zqrySubjectsAfterPost(DataSet: TDataSet); begin zqrySubjects.Close; zqrySubjects.Open; end; did the trick

Why not simply zqrySubjects.Refresh?
That's what I usually do.

Bye

Luca Olivetti Wetron Automatizaci?n S.A. http://www.wetron.es/ Tel. +34 93 5883004 (Ext.133) Fax +34 93 5883007

Reply by email