update code works for modify but not add new

I have these 2 lines of code for both saving new record and modifying existing record,


            this.staffBindingSource.EndEdit();
            this.staffTableAdapter.Update(this.hPMDataSet.staff);

however, it only works for modifying new record, but not saving the new record, seems that it does update the actual database for the changes made to existing records, but doesn't update database with the new record. please help




Answer this question

update code works for modify but not add new

  • Chris Doull

    well, now it worked without a change, i dont know why......

  • bw12117

    well, i have 2 buttons, "add new" and "save"

    buttonAddNew has code "this.staffBindingSource.AddNew();"

    buttonSave has those 2 lines of code.

    btw, i set my database file to "copy if newer"

    this is really wierd because i had exactly the same code for another app, but no problem at all



  • ChooJunwen

    The code should work. How is it being called


  • update code works for modify but not add new