none
TableAdapterManager changes detail row state but does not save it to database RRS feed

  • Question

  • We have a SQL Server master table with pk identity column and a detail table with pk identity column and foreign key to master.

    In C#.net a typed dataset with both tables and a relation with "both relation and fk constraint" + cascade 3 times.

    Inserting a master+save to db then adding detail row +save to db works.

    But: We insert a new master row and two detail rows to the typed dataset.

    UpdateAll with UpdateInsertDelete only stores master on db but not details AND sets details.rowstate to unchanged.

    UpdateAll with InsertUpdateDelete returns a concurrency exception

    What are we doing wrong?

    • Moved by Anne Jing Friday, June 27, 2014 2:49 AM
    Wednesday, June 25, 2014 1:59 PM

All replies

  • Hi,

    Accroding to your description, I am afraid your problem is out of support in C# forum. I move your thread to ADO.NET DataSet forum. You can get more professional help in there!

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, June 27, 2014 2:49 AM
  • Hello,

    >>We insert a new master row and two detail rows to the typed dataset.UpdateAll with UpdateInsertDelete only stores master on db but not details AND sets details.rowstate to unchanged.

    UpdateAll with InsertUpdateDelete returns a concurrency exception.What are we doing wrong?

    What is the concurrency message? Please share it with us.

    And as far as I know, for the typed dataset, if you inserts data into master and detail tables at the same time, since the master table primary key field is identity, it would be generated in the database, while at that time the detail dose not know exact foreign key, as I know it would be -1 by default, that means it will try insert the -1 as the foreign key value. For such an scenario, it is recommended to change your master primary key field to be non-identity.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, June 30, 2014 6:54 AM
    Moderator
  • Seems you use the wrong update method.


    Success
    Cor

    Wednesday, July 2, 2014 7:13 AM