Altering DB table, adding a column - getting error in Android

I have the following method obtained and modified from a very old post on the forum which adds a column to a db table to an already existing table. I use this same function for desktop and iOS, but I am getting a crash on Android. The error is “Column ColumnName does not exist”

CreateColumn(DB As SQLiteDatabase, tableName As String, mName As String, mType as String) As Boolean

// Check Column Schema to see if Column exists
Dim rs as RowSet
Dim COLExists As Boolean
Dim COLCreated As Boolean

rs = theDB.TableColumns(tableName)

If rs <> nil then
  While Not rs.AfterLastRow
    If rs.Column("ColumnName").StringValue = mName then  'XX crashes here
      COLExists = True
    End If
    rs.MoveToNextRow
  Wend
End If

// Create column if it doesn't exist
If NOT COLExists Then 
  theDB.ExecuteSQL("ALTER TABLE " + tableName + " ADD COLUMN " + mName + " " + mType)
  
  COLExists = True
  COLCreated = True
Else
  COLCreated = False
End If

Return ColCreated

The above is called in another method to see if the db is newer:

dim chkCol as Boolean
chkCol = CreateColumns(myDB, "myTableName", "MyNewColumnToAdd", "TEXT")

Any idea as to why this would not work on Android?

If you break your code after you get TableColumns, you can see that there isn’t a field named “ColumnName”, but simply “Name”.

Moreover the all rowset fields are different and with different name
So you have to change your code or wrap it in a #if targetAndroid

That is interesting. I added a breakpoint where you suggested on both Android and iOS projects and can see the differences in the names and fields. Thanks for pointing this out!