JetEntityFrameworkProvider icon indicating copy to clipboard operation
JetEntityFrameworkProvider copied to clipboard

Cannot update record (query '' is corrupt)

Open jpsemery opened this issue 2 years ago • 0 comments

Hi

I successfully integrated JetEntityFrameworkProvider and can read and add records and. Any time I want to update a record I get and exception on SaveChanges(). the inner exception says "Query '' is corrupt". here is my code. data is not null so the else branch is used. I just hardcoded one change to limit errors:

    public ProductionStatusData AddOrUpdateProductionData(ProductionStatusData item, int retry = 0)
    {
        AccessDbContext context = new AccessDbContext(_dbConnection);

        ProductionStatusData data = context.ProductionStatusData.FirstOrDefault(x => x.Id == item.Id);

        if (data == null)
        {
            data = context.ProductionStatusData.Add(item);
        }
        else
        {
            data.NumCandidates = 99;
            //data = item.CopyTo(data);
            context.Entry(data).State = EntityState.Modified;
        }

        context.SaveChanges();
        return data;
    }

SQL statement trace and exception

ExecuteNonQuery========== update [ProductionStatusData] set [AutoUpdate] = @p0, [BallotIssue] = @p1, [Ed] = @p2, [EventId] = @p3, [Generate] = @p4, [HqApprovedFlag] = @p5, [LocFinalized] = @p6, [NumCandidates] = @p7, [PdfGenerated] = @p8, [ReportGenerated] = @p9, [ReportIssue] = @p10, [ReportPath] = @p11, [PdfPath] = @p12, [RoApprovedFlag] = @p13, [SentToHq] = @p14, [SentToRoTime] = @p15, [RoResponseStatus] = @p16, [SentToPrinter] = @p17, [SentToRo] = @p18 where ([Id] = @p19)

@p0 = True @p1 = @p2 = 10002 @p3 = 1 @p4 = False @p5 = 0 @p6 = True @p7 = 99 @p8 = False @p9 = False @p10 = @p11 = @p12 = @p13 = 0 @p14 = False @p15 = 1899-12-30 12:00:00 AM @p16 = 0 @p17 = False @p18 = False @p19 = 2

Exception thrown: 'System.Data.Entity.Infrastructure.DbUpdateException' in EntityFramework.dll AccessDb - AddOrUpdateProductionData @ 203: System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.Entity.Core.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.OleDb.OleDbException: Query '' is corrupt. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at JetEntityFrameworkProvider.JetCommand.ExecuteNonQuery() at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<NonQuery>b__0(DbCommand t, DbCommandInterceptionContext1 c) at System.Data.Entity.Infrastructure.Interception.InternalDispatcher1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func3 operation, TInterceptionContext interceptionContext, Action3 executing, Action3 executed) at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext) at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteNonQuery() at System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.Execute(Dictionary2 identifierValues, List1 generatedValues) at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update() --- End of inner exception stack trace --- at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update() at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.<Update>b__2(UpdateTranslator ut) at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update[T](T noChangesResult, Func2 updateFunction) at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update() at System.Data.Entity.Core.Objects.ObjectContext.<SaveChangesToStore>b__35() at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction) at System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass2a.<SaveChangesInternal>b__27() at System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult](Func1 operation) at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction) at System.Data.Entity.Core.Objects.ObjectContext.SaveChanges(SaveOptions options) at System.Data.Entity.Internal.InternalContext.SaveChanges() --- End of inner exception stack trace --- at System.Data.Entity.Internal.InternalContext.SaveChanges() at System.Data.Entity.Internal.LazyInternalContext.SaveChanges() at System.Data.Entity.DbContext.SaveChanges() at xyz.Databases.AccessDb.AddOrUpdateProductionData(ProductionStatusData item, Int32 retry) in C:\REPOS\xyz\xyz\Databases\AccessDb.cs:line 199

Thanks a bunch for your help

jpsemery avatar Apr 28 '22 16:04 jpsemery