none
problems with DataTable.AcceptChanges method RRS feed

  • Question

  • Hi all,

     

    I am trying to update two tables with a parent - child relation using the following commands

     

    daParent.Update(MyDataset,"ParentTable")

    daChild.Update(MyDataset,"ChildTable")

     

    The first update is ok, but the second is never executed, because the DataRowState property of the child table's

     

    rows takes the Unchanged value.

     

    I know it has got to do with the AcceptChanges method, which is called immediately after the update method, but why

     

    does the AcceptChanges method affect the child table rows, when it should affect only the parent table's rows??

     

     

    Any ideas???

     

    Thank u for your time

     

    Panos

     

     

     

     

    Monday, February 18, 2008 3:00 PM

Answers

  • The DataRelation also allows you to control whether or not AcceptChanges on the parent row (or table) will also call AcceptChanges on the child.

     

    Monday, February 18, 2008 9:38 PM

All replies

  • Why don't you call Update on the dataset itself rather then on tables separately?

    Monday, February 18, 2008 5:18 PM
  • I update them separately, because i need to retrieve the autonumber value of the ID field which is common to both of

     

    them, in order to maintain their relationship. 

     

     

     

     

    Monday, February 18, 2008 6:18 PM
  • If you setup Parent/Child relationship between the two tables using DataRelation Class the chils will be automatically updated by the generated values from parent table.
    Monday, February 18, 2008 7:03 PM
  • The DataRelation also allows you to control whether or not AcceptChanges on the parent row (or table) will also call AcceptChanges on the child.

     

    Monday, February 18, 2008 9:38 PM
  • Robert,

     

    After i read your post, i remembered that i had set the accept/reject rule of the DataRelation to cascade. I set it back to

     

    none and it worked

     

    Thank u very much Robert and Giorgi

     

    Panos

     

     

     

    Tuesday, February 19, 2008 1:52 PM