My project can be upgraded by the user from SQLite to CubeSQL. I use db as Database as a property of the app and instantiate it as either SQLiteDatabase or CubeSQL. LastRowID is a method of both SQLite and Cube, but I cannot figure out how to subclass Database to include the LastRowID method.
You can’t subclass database like that. Instead you’ll need to cast it to the appropriate type to get LastRowID.
Dim lastID As Integer
If App.DB IsA SQLiteDatabase Then
lastID = SQLiteDatabase(App.DB).LastRowID
ElseIf App.DB IsA CubeSQLDatabase Then
lastID = CubeSQLDatabase(App.DB).LastRowID
Take the above and put it in an extends method in a module:
Function LastRowID(Extends DB as Database) As Integer
If DB IsA SQLiteDatabase Then
ElseIf DB IsA CubeSQLDatabase Then
'raise an exception
Now you can use
X = theDatabase.LastRowID