1

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.

Sheena
  • 15,590
  • 14
  • 75
  • 113
  • You're using a typed datatable/adapter, so you should use the auto generated methods like `NewTblProfileRow`, `AddTblProfileRow`. Then you can also use the strongly typed properties like `newRow.OrgName = txtOrgName.Text` and so on. – Tim Schmelter Jun 25 '14 at 08:57
  • I think you may be checking the wrong database... There is a |DataDirectory| to store database, your update command is updating that database and when you retrieve that row it is also against this database. But when you are viewing your database, I think that is a different database it is in your project folder. – Syed Farjad Zia Zaidi Jun 25 '14 at 09:07
  • @TimSchmelter: That was the original approach but had the same effect – Sheena Jun 25 '14 at 09:23
  • @SyedFarjadZiaZaidi: I don't think so. Since I am using the same connection string for update as I am using for the default DataGrid view. And the view shows the manually entered data. – Sheena Jun 25 '14 at 09:25

0 Answers0