Lazarus
Programming => Packages and Libraries => Topic started by: Fabius on June 16, 2021, 05:18:48 pm
-
Good morning all :)
I have an error message during execution ( compile OK )
dataset error, not in insert or edit mode
I tried with Append and insert
i still have an error
According to you or am I wrong?
Thank for Help ;D
My Code
lignesDeSaisie = Tdbf
On button command
Juste this
Try
lignesDeSaisie.Append;
/////lignesDeSaisie.Insert;
lignesDeSaisie.FieldByName('compte').AsString := Form1.Xcomptes.FieldByName('compte').AsString;
lignesDeSaisie.FieldByName('label').AsString := Form1.Xcomptes.FieldByName('label').AsString;
lignesDeSaisie.Post;
finally
end;
-
Hi
You did not set the DB in the edit mode.
After insert or append you have to do
And please: use code formatting for your code!
Winni
-
Ok , Thank ;D , I test
-
I have tested
lignesDeSaisie.Append;
///lignesDeSaisie.Edit;
lignesDeSaisie.FieldByName('compte').AsString := Form1.Xcomptes.FieldByName('compte').AsString;
lignesDeSaisie.FieldByName('label').AsString := Form1.Xcomptes.FieldByName('label').AsString;
lignesDeSaisie.FieldByName('credit').AsFloat := 0;
lignesDeSaisie.FieldByName('debit').AsFloat := 0;
///lignesDeSaisie.Post;
If I del the line post , it's OK
???
-
The code which you show is correct. When it is not working then there must be something in your code which must put the dataset back into browse mode before you call dataset.Post. Convince yourself by means of the attached demo which simply does the same as in your code.
Make a backup of your project and remove all unnecessary parts. Usually you can find the issue this way by yourself. If not, pack the .pas, lfm, lpr, lpi and dbf files into a common zip which you can upload here.