Database.AddRow

From Xojo Documentation

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

Database.AddRow(TableName as String, row as DatabaseRow)

New in 2019r2

Supported for all project types and targets.

Inserts Data (a populated DatabaseRow) as a new row in TableName.

Notes

Always look for a DatabaseException to verify whether or not the data was added.

Sample Code

This code adds a row to an existing Team table with the columns "Name", "Coach" and "City". It's assumed that the variable db contains an active database connection:

Var row As New DatabaseRow
// ID will be updated automatically
row.Column("Name") = "Penguins"
row.Column("Coach") = "Bob Roberts"
row.Column("City") = "Boston"

Try
db.AddRow("Team", row)
Catch error As DatabaseException
MessageBox("DB Error: " + error.Message)
End Try