Lazarus

Programming => Packages and Libraries => Topic started by: Fabius on June 16, 2021, 05:18:48 pm

Title: Dbf Append , Error ?
Post 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;


 
Title: Re: Dbf Append , Error ?
Post by: winni on June 16, 2021, 06:03:32 pm
Hi

You did not set the DB in the edit mode.

After insert or append you have to do

Code: Pascal  [Select][+][-]
  1. lignesDeSaisie.Edit;
  2.  


And please: use code formatting for your code!

Winni
Title: Re: Dbf Append , Error ?
Post by: Fabius on June 16, 2021, 06:37:31 pm
Ok , Thank  ;D , I test
Title: Re: Dbf Append , Error ?
Post by: Fabius on June 16, 2021, 06:41:28 pm


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

???
Title: Re: Dbf Append , Error ?
Post by: wp on June 16, 2021, 09:27:38 pm
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.
TinyPortal © 2005-2018