Database.AddRow

From Xojo Documentation

Revision as of 18:48, 12 November 2019 by PLefebvre (talk | contribs) (Sample Code)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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