I'm reading data from SQLite database table.
If the SQLiteDataReader encounters a negative double an InvalidCastException is thrown.
Here is my code.
public void DBToArray()
{
string stm = "SELECT * FROM mtable";
SQLiteCommand cmd = new SQLiteCommand(stm, sqlcon);
SQLiteDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
Console.WriteLine(
rdr.GetInt32(0) + " " +
rdr.GetString(1) + " " +
rdr.GetString(2) + " " +
rdr.GetString(3) + " " +
rdr.GetInt32(4) + " " +
rdr.GetDouble(5) + " " + /* -5.0 no good */
rdr.GetString(6) + " " +
rdr.GetString(7)
);
}
}
Just wondering if anyone has encountered and solved this issue?
I could make that particular double column a string and cast it later with Convert.ToDouble
but I'd sooner not if there is another solution.
I cannot find any information on System.Data.SQLite having a problem with negative double.
Thanks for looking.