Forum > LCL
Error dbf post ( resolu )
(1/1)
Fabius:
Good morning all
It compiles, but at runtime, I have an error, the dataset is not in add or edit mode
While I have placed the APPEND command?
or do I make a mistake?
Thank you for your reply
procedure TForm3.Button4Click(Sender: TObject);
begin
//////////////////ajouter en fin de table
if DBEdit1.text <>'' then
begin
DBEdit1.Color := clGreen;
lignesDeSaisie.Last;
Try
lignesDeSaisie.Append;
lignesDeSaisie.FieldByName('compte').AsString := Form1.Xcomptes.FieldByName('compte').AsString;
lignesDeSaisie.FieldByName('label').AsString := Form1.Xcomptes.FieldByName('label').AsString;
lignesDeSaisie.Post;
finally
end;
DBEdit3.SetFocus;
end else begin
DBEdit1.Color := clRed ;
messagedlg('Compte NON Trouvé Ou Vide .',mtinformation,[mbok],0);
StatusBar1.SimpleText:= 'Ce compte n existe pas ';
end;
end;
wp:
Your code suggests that you enter the text first, then call Dataset.Append, transfer the edit text and finally post. This is possible with normal TEdit controls, but not with TDBEdit. Since the DBEdit reflects the state of the dataset you cannot enter anything before the dataset has not been switched to edit mode. Therefore, you first must call Dataset.Append, type the text and then Post.
See a working example with TDBEdit in the attachment.
Fabius:
Tank You
It the DBEdit3.SetFocus; the probleme :-\
Navigation
[0] Message Index