Skip to content

DatabaseRow Changes

As part of API 2.0, the DatabaseRow class was introduced alongside RowSet and DatabaseColumn. These three classes replace DatabaseRecord, RecordSet and DatabaseField respectively. In 2019r2.1 we also changed the initial implementation of DatabaseRow a bit; this will require you to make some minor changes if you used it in 2019r2.

Previously, DatabaseRow had separate methods for adding and changing column values. This was how DatabaseRecord also worked, but we realized this was confusing when we started using DatabaseRow for the RowSet iterator in API 2.0. So now, the Column and ColumnAt methods on DatabaseRow return a DatabaseColumn so you can set and change values more consistently.

Speaking of which, you can now loop through a RowSet by using an iterator rather than having a While loop and calling the MoveNext method. Previously you might write code like this in API 1.0:

While Not rs.EOF
  Dim nameValue As String = rs.Field("FirstName").StringValue

With API 2.0 starting with 2019r2.1 you can use an iterator like this:

For Each row As DatabaseRow In rs
  Var nameValue As String = row.Column("FirstName").StringValue

This is now a bit cleaner as you don’t have to remember to move to the next row, although that syntax continues to work, of course, with slight API 2.0 modification:

While Not rs.AfterLastRow
  Var nameValue As String = rs.Column("FirstName").StringValue

If you had used DatabaseRow with an iterator in 2019r2, then you’ll need to tweak your code to use the Column methods and DatabaseColumn properties instead of the older DatabaseRow methods. For example if you were doing this:

Var age As Integer = row.IntegerColumn("Age")

You would now instead do this:

Var age As Integer = row.Column("Age").IntegerValue

Xojo 2019r2.1 is available for download now.