First off: trying to get the "last" PrimaryKey the way you showed is nonsense.
Why "1"? Sort your Grid by something else than ID, and you'll see (either "pre-sorted" by the underlying Query, or by User-Action).
Why "2"? Through time you'll probably have "gaps" between ROWID's. Now insert a new record using a "free" value for your ID, that's somewhere "in between" two already existing rows
Next: Why querying "rowid" at all? If you have a PrimaryKey of Datatype Integer, this field (usually "ID") becomes an Alias for ROWID,
and you shouldn't have any Problems accessing that Field
Next: Is this Primary Key you have there setup as AUTOINCREMENT? (I hope not, because in SQLite you don't need it)
If yes, there might be a way through a "backdoor"
EDIT: And GetMem showed the usually accepted way, except returning your PK instead of rowid
btw: If you're using the SQLite-specific Connection-Objects, i wouldn't be surprised to find a "LastInsertRow"-Function in either the Connection or the Query-Object