Debugging foreign key issue

Debugging foreign key issue

  
Hello,

I have been following the tutorials, and I must have made an error along the way, now getting an error on INSERT with foreign key issue.
I thought this was a good opportunity to learn how the debugger works, so have set up some break points and trying to step through the problem.
My trouble is, it seems that there is a discrepancy in the filter because the relationship has some error.
How can I see the actual INSERT statement that is being executed?  I only know there is an INSERT from the error message, but cannot figure out how to look at the actual SQL statement.
This is the error message coming up, in Save command.
The INSERT statement conflicted with the FOREIGN KEY constraint "OSFRK_OSUSR_L2M_ORDERITEM_OSUSR_L2M_ORDER_ORDERID". The conflict occurred in database "K1VTXU003", table "dbo.OSUSR_L2M_ORDER", column 'ID'.

Please advise.
Solution
Hi Yokho,

The only way to get to the actual INSERT statement is to use tooling of the database. However, you shouldn't need to do that in this case.

As you can see from the error message, there's a foreign key constraint conflict. This means that you try to INSERT a record (i.e. create a new one) that has an identifier of another table as one of its attributes, but that attribute is not filled correctly (i.e. either empty but it's mandatory, or filled with a value that does not exist in the referenced table).

Judging from the error message, you are trying to Create an OrderItem, but the mandatory OrderId is not filled correctly. You probably left it empty?
Solution
Yes, you were right, I needed another asign to fill the foreign key.  Thank you!