Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
405
ForeignKeyConstraint id requires the child key values (0) to exist in the parent table
posted

I am having a WHDG with manual CRUD operations. It works fine at Parent level but I am getting "ForeignKeyConstraint id requires the child key values (0) to exist in the parent table" every time I need to add a new row at the child band. Datasource is a dataset that gets repopulated at every postback from a call to the DB.

Thanks

  • 7499
    posted

    Hello Jwquiroz,

    If I can be of any further assistance with this matter please let me know

  • 7499
    posted

    Hello Jwquiroz,

    The error means that your code tries to create some record in child table, but does not have any parent record. Since you have constraint (foreign key) that enforces data integrity, you would receive this error.

    Remember that the dataset is an in-memory cache for the data vs the data in the database. The relationship is setup so the foreign key constraint is enabled to the datatables in the dataset (not in the database). If you still face the issue, please post the code so that I may further assist you.

    Please let me know if you have any further questions regarding this matter.