Inserting a Child Record Fails After Inserting Parent! RRS feed

  • Question

  • Hi All,

    I am implementing a simple master/details application. It contains a form that has details controls that represent Orders and a DataGridView that represent OrderDetails. The PK of Orders is generated automatically.

    Consider the following scenario that I implemented when the inserting new record in Orders and OrderDetails:

    * Note that the DataSet I am working on the the following steps contains only added records.

    1. First, I am updating the Orders through it's TableAdapter, which is updated successfully. Note that the Orders record has a temporary ID in the DataSet before the update. However, the ID is modified after update to the one generated by the DB. Also, the ID, which is a FK in OrderDetails is updated consequently in the DataSet.

    2. Then, I update the OrderDetails, which doesn't take place on the DB. After investigating, I figured out the row state of records is changed to "UnChanged" (just after updating Orders) instead of "Added" therefore the update fails!

    That is a strage behavior! Any suggestions of how to overcome it?


    Sunday, January 25, 2009 9:59 AM