locked
Can't save changes done to access database

    Question

  •  

    I tried everything with this and I cannot save changes done to access database, I was looking at many solution find on google, but none of them worked. This is the source code:

     

    dataDataSet.Table1Row row = dataDataSet1.Table1.NewTable1Row();

    row.f1 = textBox1.Text;

    row.f2 = "Piotrek";

    dataDataSet1.Table1.Rows.Add(row);

    //dataDataSet1.AcceptChanges();

    table1TableAdapter1.Update(dataDataSet1.Table1);

     

    I will appreciate any help.

    Wednesday, August 20, 2008 2:50 PM

Answers

  • AcceptChanges updates the DataSet only. Remember the DataSet is disconnected architecture. The Update method will propagate the DataSet back to the Source.

     

    Read MSDN documentation

     

    Thursday, August 21, 2008 1:31 PM

All replies

  • Have you associated the Update Method with an Update Command?

    Wednesday, August 20, 2008 5:13 PM
  • That is because a new datarow is an INSERT not an UPDATE.

     

    A.D.T.

     

    Wednesday, August 20, 2008 6:35 PM
  • You are calling the Update method in the Dataset class. What is the command that that method is associated with? Do you not understand my question?

    Wednesday, August 20, 2008 6:44 PM
  •  

    To be honest, I am not an expert in this. Anyway the line that was marked as comment in above code, was not marked in my application. After I removed it, it worked. However I would like to know what should be the proper way. I am not sure what you mean saying method associated with command.

     

    When I was looking on MSDN it was saying AcceptChanges method is the one commiting all changes done since last use of this method. However it does not seem to work at all.

    Thursday, August 21, 2008 9:03 AM
  • AcceptChanges updates the DataSet only. Remember the DataSet is disconnected architecture. The Update method will propagate the DataSet back to the Source.

     

    Read MSDN documentation

     

    Thursday, August 21, 2008 1:31 PM
  • Thanks for help!

    Thursday, August 21, 2008 4:32 PM