Firedac SQLite returning wrong values

I have a SQLite database that contains a table called "players". I can see in DB Browser that the data in the table is correct however when attempting to retrieve the data it seems to be returning a totally different value than what's in the database.

Value in DB: 76561198113034550

Value returned : 152768822

I'm getting the value with the following

qryPlayers.Close;
qryPlayers.SQL.Text := 'SELECT * FROM players';
qryPlayers.Open;

playerID := qryPlayers.FieldByName('steamid').Value; // .AsString returns the same value

Whats causing this and how can I fix it?


Solution 1:

I just checked, what value the 4 lower bytes of 76561198113034550 have... And tadaaa, it is 152768822! So the upper 4 bytes are simply truncated.

Declare playerID as Int64, not Integer or Cardinal since those types only have 4 bytes in memory.
And for retrieving the value from the DB use qryPlayers.FieldByName('steamid').AsLargeInt.