Invalid cast exception when using DataReader's GetString method on a string value that happens to be a string representation of an integer
|User & Date:||mistachkin 2018-09-02 17:51:20|
- Change icomment to:
I'm able to reproduce the exception here. The root cause of this issue is that the SQLite core library returns 'integer' affinity for the second value, partly due to its not considering the declared column type ('String') to have textual affinity.
Everything appears to be working as designed. There are two potential solutions to this issue:
1. Change the column type to be 'TEXT' instead of 'String', which should cause the SQLite core library to return 'TEXT' affinity for the column value, even if it looks like an integer.
2. Use the connection flag 'NoVerifyTextAffinity', which will prevent exceptions from being thrown by the System.Data.SQLite type conversion subsystem.
The #1 solution is preferred in this case, if possible, because it reduces the amount of unnecessary type conversion work performed by the SQLite core library and the System.Data.SQLite code.
- Change login to "mistachkin"
- Change mimetype to "text/x-fossil-plain"
- Change resolution to "Works_As_Designed"
- Change status to "Pending"