hsm2100

hsm2100

  • NA
  • 1
  • 0

A problem with the tableAdapterManager in a master-details form

Jul 16 2008 4:33 PM
Hello,

    I am writing an application in visual studio 2008 and I have the Dataset connecting to a SQL server 2005 with 2 tabes : Check( chkID,ChkAmount) and checkDetails (chkDetailsID,ChkID,Amount,Deduction). Each table has its ID of autonumber type.
    I have a master details form for these 2 tables when I add a new check record it is automatically assigned an temporary ID -1 untill it is saved in the database when I add a checkDetails record for this new added check it is given in the foreign Key "chkID" a value of -1 also

The problem when I press the save button which has the following code it raises an exception at the tableAdabtermanager.UpdateAll statement


private void checkBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.checkBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.eshpetcoDBSDataSet);

        }

The exception of type sqlexception says The INSERT statement conflicted with the FOREIGN KEY constraint "Check_CheckDetails_FK1". The conflict occurred in database "EshpetcoDBS", table "Finance.Check", column 'chkID'.
The statement has been terminated.


I understand that the tableadaptermanager should handle the order of inserts and updates.but I dont know why it isnt working