RowSet.EditRow

From Xojo Documentation

Method

RowSet.EditRow()

New in 2019r2

Supported for all project types and targets.

Call EditRow prior to performing modifications to the current row. Be sure the SQL includes the primary key column (or columns) so that you can update the table after making changes. Changes are only saved to the DB when RowSet.SaveRow is called.

Notes

If the row is locked, a DatabaseException is raised. Check the Error and Message properties of DatabaseException after calling this method to determine if that occurred.

A RowSet is populated in memory when you call the SelectSQL method. If you use MoveToPreviousRow to go back to prior rows (including those that you have changed using the EditRow method), then you will get the values that were originally populated, not the changed values.

Editing with MySQL

MySQL cannot guarantee the contents of a RowSet after issuing an Update call (after having previously called EditRow). This means you should not try to modify the contents of a RowSet in a loop. Instead select just the single row you wish to modify.

Sample Code

Set the string value of a column in a RowSet:

// rs is a RowSet with a column called "ProductName":
Try
rs.EditRow
rs.Column("ProductName").StringValue = "Generic Widgets"
rs.SaveRow
Catch error As DatabaseException
MsgBox("DB Error: " + error.Message)
End Try