System.Data.SQLite
Ticket Change Details
Not logged in
Overview

Artifact ID: 89816df7f19ff83c2bbc0aefdd4685ee68081ba6
Ticket: 458738515e70f99f0ce997894c9602bfce9cb2ed
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
Changes

  1. 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.

  2. Change login to "mistachkin"
  3. Change mimetype to "text/x-fossil-plain"
  4. Change resolution to "Works_As_Designed"
  5. Change status to "Pending"