DatabaseRow Example

The example from DatabaseRow does not use CommitTransaction nor RolbackTransation (as well as it was in 2015r1)…

Talking about 2015r1, my small project does not write my record to disk and report no error.

On the other end, the similar example with recent Xojo / M1, works fine (I do not noticed error while writing a Record).

I wanted to use InsertRecord, but failed to do so (how to pass TextField / TextArea contents ?)…

To use a Commit or Rollback statement, there must first be a BeginTransaction. Without an active transaction, instructions to the database are executed immediately and a Commit will occur if the instruction is successful while an error will cause a Rollback.

To use InsertRecord, you need to create the record and assign the values from the textfield/textarea to the fields in the record. The fields in the record must exist in the table you are adding the record to or an error will be raised.

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

That is the base example I used without transaction nor commit/rollback that do not worked on Xojo 2015r1.

Once I added the missing parts, the “write ‘A’ Record” lethod wrote the data to disk.

Ans, as I already stated, I was curious to know how this works in current Xojo: it goes fine without “transaction nor commit/rollback”.

Now the Custom Icon loaded with a script…