Robin Rodricks
Robin Rodricks

Reputation: 113956

Get the row ID within an SQLiteDataReader

Is it possible to get the rowid of the record when using "SELECT * from table"? Does the SQLiteDataReader class have a way of doing that internally?

Currently I can only read the rowid if I use "SELECT rowid, name, description from table".

I then use GetValue(0) to then read the rowid.

Upvotes: 1

Views: 1603

Answers (1)

Robin Rodricks
Robin Rodricks

Reputation: 113956

This did the trick for me!

SELECT rowid, * from table

According to Tim Schmelter, the datareader can only give you the values that you've selected. But I don't know the column names of the table, so by appending rowid to * we get the best of both worlds.

Upvotes: 3

Related Questions