Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see Why Migrate to InterSystems IRIS?

UpdateContact

The UpdateContact method saves any changes made to a contact's information through the Edit Contact Information GUI panel. The method is invoked by the event handler for the Update button. This event handler is already coded. UpdateContact does the following:

  1. Reads the Contact ID from the text box on the GUI panel.

  2. Uses the Find method of the ADO.NET DataRowCollection class to locate the row in the Contacts data table with the correct ID value.

  3. Invokes BeginEdit on the DataRow to put the row into Edit mode.

  4. Updates the values in the DataRow columns.

  5. Invokes EndEdit on the DataRow to take the row out of Edit mode.

  6. Invokes Update on conAdapter. This is the CacheDataAdapter object that connnects the data set to the Provider.Contact table. Update propagates the changes to the data set data to Caché. It also reloads the Caché data into the data set.

  7. Invokes DisplayTreeView to redisplay the data in the GUI's tree.

Add the method body to the UpdateContact stub in PhoneForm.cs.


private void UpdateContact()
{
 DataRow targetRow = ds.Tables["Contacts"].Rows.Find(txtConId.Text);

 targetRow.BeginEdit();
 targetRow["Name"] = txtConName.Text;
 targetRow["ContactType"] = comboBox1.SelectedItem.ToString();
 targetRow.EndEdit();

 conAdapter.Update(ds, "Contacts");
 DisplayTreeView();
}   
Feedback