[Lazarus] [lazarus] Advice about creating database-aware application with Lazarus
Joost van der Sluis
joost at cnoc.nl
Sun Jun 22 16:03:17 CEST 2008
Op zaterdag 21-06-2008 om 20:06 uur [tijdzone -0600], schreef Howard Lee
Harkness:
> At that point, I could insert a record, but not edit or delete a
> record. So, I tried the following:
>
> procedure TForm1.DBNavigator1Click(Sender: TObject; Button:
> TDBNavButtonType);
> begin
> case Button of
> nbDelete,
> nbPost: begin
> SQLQuery1.DisableControls;
> SQLQuery1.ApplyUpdates;
> SQLQuery1.EnableControls;
> end;
> nbRefresh: begin
> SQLQuery1.Close;
> SQLQuery1.Open;
> end;
> end;
> end;
>
> Lo, and behold! I could now insert a record, and delete a record!!!
> Elated, I tried the following:
My question is why you did DBNavigator1Click at all? On nbPost, it
should call - first of all - SQLQuery1.Post. You forgot that. (I guess
that that's your edit-problem) Normally, if you don't implement
DBNavigator1Click it will do that automatically.
If you want the changed to be committed to the underlying database
immediately (Is that a good design?) then you can add the
disable-apply-enable sequence to the SQLQuery1.AfterScroll event. Then
you don't need the DBNavigator1Click-hack.
Joost
More information about the Lazarus
mailing list