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
The exception occurs because datareader.Item[]
returns object
.
The problem is due to boxing/unboxing. It's nothing to do with the database itself...
long a = 1;
int b = 2;
object objectA = a;
object objectB = b;
Console.WriteLine((int)a);
Console.WriteLine((long)b);
Console.WriteLine((int)objectA);
Console.WriteLine((long)objectB);
Console outputs 2 then 1, but will throw an exception on the cast of objectA
, objectB
. This is a characteristic of .NET nothing to do with ODBC drivers.