Android Question SQLITE problem. Column 'rowid' Does Not Exist?

RichardN

Well-Known Member
Licensed User
Longtime User
In a database created with SQLITE Expert pro the column 'rowid' is visible in a data view and appears to behave as expected as an 'Auto-increment' INT field. Maninipulating the data with SQL commands within SQLITE Expert referencing 'rowid' also works fine, but this.....

B4X:
Dim Companies as Cursor
Cursor = SQL.ExecQuery("SELECT * FROM Companies")
Dim rowid as Int = Companies.GetInt("rowid")

This generates a run-time error as the column 'rowid' is not found. I could add another Int-Auto-Increment field to the table but I would like to get to the bottom of this and use rowid as the designer intended.

Has anybody else seen this behaviour?
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
In a database created with SQLITE Expert pro the column 'rowid' is visible in a data view and appears to behave as expected as an 'Auto-increment' INT field. Maninipulating the data with SQL commands within SQLITE Expert referencing 'rowid' also works fine, but this.....

B4X:
Dim Companies as Cursor
Cursor = SQL.ExecQuery("SELECT * FROM Companies")
Dim rowid as Int = Companies.GetInt("rowid")

This generates a run-time error as the column 'rowid' is not found. I could add another Int-Auto-Increment field to the table but I would like to get to the bottom of this and use rowid as the designer intended.

Has anybody else seen this behaviour?

If you do Select * then rowid won't appear in the output.
So the answer is to put rowid explicitly in your select columns, eg:
select rowid, * from Companies
Not tested, but should work.

RBS
 
Upvote 0
Top