I\'m using System.Data.SQLite, selecting from a sqlite database table where a column has type \'integer\', and when I do something like this:
int x = (int)reade
As the other answerer mentioned, SQLite integer is stored in 1, 2, 3, 4, 6, or 8 bytes. However, you won't get overflow or out of range exceptions.
In that context, (int)
is a cast, not a conversion. If reader[]
didn't return an object of type integer, if it's returning a different numeric type, you will get a cast exception, regardless of the value it contains.
Based on the range of valid values for SQLite integer, I'd guess that it's returning the value as a 64-bit integer, long
. To verify, try this:
object x = reader["myColumn"];
Debug.WriteLine(x.GetType().Name);