Updating a row
To update a row in a table, first read the row with the Change() method. This retrieves the row and locks it, allowing you to make changes. Set the values of the fields you want to change for the row. Finally, use the Save() method to save the changed row back to the table.
The following C# example reads the row for Adam Park Resort. The Contact Person for this row is changed the "Steve K." Then the row is saved back to the RM_Customer_MSTR table.
// Variable for any table operation error TableError err; // Create a reference to the table RmCustomerMstrTable CustomerMasterTable; CustomerMasterTable = Dynamics.Tables.RmCustomerMstr; // Set the key to use for the table // Key 1 - Contains the Customer Number CustomerMasterTable.Key = 1; // Set the key field in the table CustomerMasterTable.CustomerNumber.Value = "ADAMPARK0001"; // Attempt to read the row. The Change() method will lock the row. err = CustomerMasterTable.Change(); if (err == TableError.NoError) { // The row was read successfully, so update the value CustomerMasterTable.ContactPerson.Value = "Steve K."; // Save the updated row err = CustomerMasterTable.Save(); if (err != TableError.NoError) { MessageBox.Show("An error occurred updating the row: " + err.ToString()); } } else { MessageBox.Show("An error occurred retrieving the row to update: " + err.ToString()); } // Close the table CustomerMasterTable.Close();