RecordSet.Edit

From Xojo Documentation

Method

RecordSet.Edit()

Supported for all project types and targets.

Call Edit prior to performing modifications to the current record. Be sure the SQL incudes the primary key column (or columns) so that you can update the table after making changes. Changes are only saved to the DB when Update is called.

Notes

Check the Database.Error property after calling this method. If the record is already locked you will see an error there and you can display the error message.

A RecordSet is populated in memory when you call the SQLSelect method. If you use MovePrevious to go back to prior records (including those that you have changed using the Edit 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 RecordSet after issuing an Update call (after having previously called Edit). This means you should not try to modify the contents of a RecordSet in a loop. Instead select just the single record you wish to modify.

Sample Code

Set the string value of a column in a RecordSet:

// rs is a RecordSet with a string column called "ProductName":
rs.Edit
If Not db.Error Then
rs.Field("ProductName").StringValue = "Generic Widgets"
rs.Update
If db.Error Then
MsgBox("DB Error: " + db.ErrorMessage)
End If
Else
MsgBox("DB Error: " + db.ErrorMessage)
End If