Crazy database results I can't manage to debug.
Hi, I'm force by a college professor, for an assignement to do integration testing of a mysql database using sqlite. So I'm using the IDbConnection, IDbCommand and IDataReader interfaces from ADO.NET to make it work with whatever.
After dealing with datetime and timestamp issues, due to the differences of the sql dialects, I'm running into into a verry annoying issue where SQLite doesn't let you specify the length of integers you want (no need to do so according to it's documentation as it adapst by itself depending based on the length of the value you insert).
the problem is that if I don't do this then sometimes sqlite decides it's gonna be a System.Int64 and I therefore need to cast it into a long before casting it into an int. I don't know why sqlite does this as every value I ever insert into the database is under the 2 billion something max value for a signed int on 32bits.
Is there a way, without knowing the type before runtime to just makes whatever type of int its going to be into an System.Int32 regardless of the number of bits it was originally stored on. (reader can be acessed as a dictionnary of objects) ?
5 Replies
Please use the GetX() methods
sorry for the formatting, this is probably not great but it seems to dot he trick, I haven't found anything when typing GetX into my IDE and when googling (GetX() methods C#) it get java related things.
IDataReader Interface (System.Data)
Provides a means of reading one or more forward-only streams of result sets obtained by executing a command at a data source, and is implemented by .NET data providers that access relational databases.
There's GetX() methods on the IDataReader to get the right type
oh thanks
I might tell that to my college teacher, after I'm done with the assignement that is