Difference between revisions of "Database.InsertRecord"

From Xojo Documentation

m (Text replacement - "{{Deprecated" to "{{DeprecatedItem")
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{Deprecated|version=2019r2|replacement=[[Database.InsertRow]]}}
+
{{DeprecatedItem|version=2019r2|replacement=[[Database.AddRow]]}}
 
{{MethodBox
 
{{MethodBox
 
| name=InsertRecord
 
| name=InsertRecord

Latest revision as of 19:02, 3 September 2020

Method

Database.InsertRecord(TableName as String,Data as DatabaseRecord)

Supported for all project types and targets.

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

Notes

Always check the Error property to verity that the data was added.

Sample Code

This code adds a row to an existing Team table with the columns "Name", "Coach" and "City":

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

App.DB.InsertRecord("Team", row)

If App.DB.Error Then
MsgBox("DB Error: " + App.DB.ErrorMessage)
End If