RowSet.SaveRow

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Method

RowSet.SaveRow()

New in 2019r2

Supported for all project types and targets.

Call to save changes to the current row in the RowSet.

Notes

If the row could not be saved, a DatabaseException is raised. Always call SaveRow inside a Try-Catch where you check for a DatabaseException. You can display the error message from the DatabaseException's Error and/or Message properties.

Some databases do not allow you to save if the SQL statement used to get the RowSet contains more than one table. Additionally, some databases may require that the SQL statement specifically include the Primary Key for the table.

Saving with MySQL

MySQL cannot guarantee the contents of a RowSet after issuing an SaveRow call (after having previously called EditRow). This means you should not try to modify the contents of a RowSet in a loop. Instead, use a separate Database.SelectSQL call to get the single Row you wish to change.

Example

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