问题
I know this question has been asked to death but none of the solutions I have found thus far have worked...
I use the following code to update a row in a table:
LocalDBDataSetTableAdapters.tblProfileTableAdapter adapter = new LocalDBDataSetTableAdapters.tblProfileTableAdapter();
LocalDBDataSet.tblProfileDataTable table = new LocalDBDataSet.tblProfileDataTable();
//adapter.Fill(table);
DataRow newRow = table.NewRow();
newRow[0] = txtOrgName.Text;
newRow[1] = txtNPONum.Text;
newRow[2] = txtContactPerson.Text;
newRow[3] = txtContactNumber.Text;
newRow[4] = txtEmailAddress.Text;
table.Rows.Add(newRow);
adapter.Update(table); //returns 1
But there are no changes in the database.
I can however select stuff from the same table successfully (I manually entered a row). So I know my connection string is correct.
So my question is:
How do I get Update to actually update?
EDIT:
I tried wrapping the lot in a transaction, thinking maybe stuff got rolled back somehow. No change.
来源:https://stackoverflow.com/questions/24404233/tableadapter-update-returns-1-but-no-changes-in-db