Problem having Instering record in the Table.

JAYESHJAYESH Member Posts: 290
Hi All,

I am tring to Insert a record in the Navision table.
I have Table and its Primary key is ID field and its auto increment field.

FADPrice is table fields are - ID, Description, Quantity, Amount.

My code is,

FADPrice.INIT;
FADPrice.Description := '12201-RAA-A0000-H1 Cyl HD';
FADPrice.Quantity := 1256;
FADPrice.Amount := 0;
FADPrice.INSERT;

FADPrice.INIT;
FADPrice.Description := 'Delta For RAA Cylinder Heads';
FADPrice.Quantity := 4563;
FADPrice.Amount := 0;
FADPrice.INSERT;

Its getting me error like ID no already exits when its tried to insert second record.

Can any one tell me why ?? what I am doing wrong.
JAYESH PATEL

Answers

  • kapamaroukapamarou Member Posts: 1,152
    You will have to assign the ID on your own through code. The id gets incremented (like in sales Lines) through the form's split property so that does not apply here.
  • JAYESHJAYESH Member Posts: 290
    I am deleting table everytime when its start to insert a record in the table.

    So, how can I find what was last ID ?

    That's why I cann't assign ID in the code.

    Its assign ID automatically for first time insert code, but only second time I get that error message.
    JAYESH PATEL
  • DaveTDaveT Member Posts: 1,039
    Hi Jayesh,

    The first insert works fine and sets the ID (e.g. = 10 ). The next INIT does not reset the primary key so the insert is tring to insert ID = 10 again. Set the ID := 0; and it should work fine
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • JAYESHJAYESH Member Posts: 290
    Thanks Dave,

    I have assigned ID = 0 in the Code, Its work fine.

    Thank you very Much :)
    JAYESH PATEL
  • DaveTDaveT Member Posts: 1,039
    Glad to Help :mrgreen:
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
Sign In or Register to comment.