TableAdapter.Update returns 1 but no changes in db

佐手、 提交于 2019-12-11 11:15:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!