in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

InvalidCastException when Integer is in a String field (1.0.66)

Last post 06-22-2010 10:49 AM by hipgnosis. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 06-22-2010 10:49 AM

    InvalidCastException when Integer is in a String field (1.0.66)

    I have a table with several string fields in it.
    I have found that if one of those fields has a value set to 1 or another integer then I get an InvalidCastException thrown :
    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Specified cast is not valid.
    at System.Data.SQLite.SQLiteDataReader.VerifyType(Int32 i, DbType typ)
    at System.Data.SQLite.SQLiteDataReader.GetString(Int32 i)
    --- End of inner exception stack trace ---
    at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[ arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
    at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[ arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[ parameters, CultureInfo culture, Boolean skipVisibilityChecks)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[ parameters, CultureInfo culture)
    at System.Data.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader`1.GetValue(DbDataReader reader, Int32 ordinal)
    at System.Data.Common.Internal.Materialization.Shaper.GetPropertyValueWithErrorHandling[TProperty](Int32 ordinal, String propertyName, String typeName)
    at lambda_method(ExecutionScope , Shaper )
    at System.Data.Common.Internal.Materialization.Shaper.HandleEntityAppendOnly[TEntity](Func`2 constructEntityDelegate, EntityKey entityKey, EntitySet entitySet) at lambda_method(ExecutionScope , Shaper )
    at System.Data.Common.Internal.Materialization.Coordinator`1.ReadNextElement(Shaper shaper)
    at System.Data.Common.Internal.Materialization.Shaper`1.SimpleEnumerator.MoveNext()
    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)


    The querying code looks like this :

    var query = from ja in te.jobs
    where ja.submitted >= dtFrom
    orderby ja.submitted ascending
    select ja;
    return query.ToList();
Page 1 of 1 (1 items)
Powered by Community Server (Commercial Edition), by Telligent Systems