Search code examples
c#data-bindingtableadapter

C# SQL DataBinder changes not saved


I have a data binder set up and the binding navigator and this is in the SAVE button code:

    private void cT_detimpBindingNavigatorSaveItem_Click_1(object sender, EventArgs e)
    {
        this.Validate();
        this.cT_detimpBindingSource.EndEdit();
        this.BindingContext[rDataSet.CT_detimp].EndCurrentEdit();
        this.tableAdapterManager.UpdateAll(this.rDataSet);

    }

I made breakpoints to be sure that the program gets to this part of the code. I made changes to one of the fields and changed records then clicked Save. I traced it to tableAdapterManager.UpdateAll --> to public virtual int UpdateAll(RDataSet dataSet) to dataSet.HasChanges() == false. I don't know why it would be false. I made the changes. Please help. I have tried it with .AcceptChangesDuringUpdate and .AcceptChangesDuringFill set at all combinations of true and false.


Solution

  • The problem was that I was using my own SQL to load the data. When I took that code out of the Form_Load method and just used the dataset that I had defined using the VS dataset wizard, it worked properly. This is all that was left in Form_Load:

    this.cT_detimpTableAdapter.FillByErrStat(this.rDataSet.CT_detimp);