I have a C# program which uses MySqlDataReader
to connect to a MySQL DB. At one point it imports a DB field of datatype double
, into a C# variable also of type double
:
MyDBTable table = new MyDBTable();
table.myDouble = row.GetValueOrDefault<double>("double_field");
But this results in the exception:
System.InvalidCastException: Specified cast is not valid.
Why am I getting this error? I thought that the MySQL double
type corresponds to the C# double
type.