“Row not found or changed” error from DataContext.SubmitChanges() after updating value on custom-built tables for Microsoft Access '97


  • Link to Stack-overflow question:


    Another dreaded "Row not found or changed" exception. 
    We're trying to update an existing entry in a table by changing one column's value.  The tables we have are specified in code section (1).  I'm getting to an instance of the `Document` Table through the code specified in code section (2) but that's where I hit an exception.

    Here are the things I have tried to resolve the issue: 
    i. tried marking every Column (in both Document and Folder) as `UpdateCheck=UpdateCheck.Never`, As well as tweaking with `CanBeNull`

    ii. tried to resolve changes after `SubmitChanges` call in part two using both `ChangeConflict.Resolve(RefreshMode.KeepChanges)` and `DataContext.Refresh(conflict, RefreshMode.KeepChanges)` on the `myContext.ChangeConflicts` set, and then do a re-`SubmitChanges`

    iii. tried disabling the EntityRef<Folder> in `Document`

    iv.  tried re-adding the `Document` table entry -- this failed because the entry does indeed exist

    Is there anything I can do short of deleting the entry from the Document table, and then re-adding it?  I'm not even sure that will work.

    Thanks for your help.


    [Table(Name = "Document")]        
    public class Document        
      [Column(Name="Folder_ID", IsPrimaryKey = true)]          
      public int Folder_ID;              
      private EntityRef<Folder> folder;             
      [Association(Storage = "folder", ThisKey = "Folder_ID", OtherKey = "Folder_ID")]          
      public Folder Folder          
      get { return folder.Entity; }              
      set { folder.Entity = value; }          
      public int Document_ID;          
      [Column(IsPrimaryKey = true)]          
      public int Image_ID;          
      public string ImageName;          
      public string ReasonForRejection;      
    [Table(Name = "Folder")]      
    public class Folder        
      [Column(Name = "Folder_ID", IsPrimaryKey = true)]          
      public int Folder_ID;          
      [Column(Name = "FolderName")]          
      public string FolderName;        


    public void MarkRejectReasonForImageID(int id, string rejReason, string dbPath)     
      // Create DataContext for MS Access '97 DB        
      DataContext myContext = new DataContext(new OleDBConnection(CreateJET4_OleDBConnectionString(dbPath));         
      // Add load options so that Folder entity is attached         
      DataLoadOptions loadOptions = new DataLoadOptions();        
      loadOptions.LoadWith<Document>(d => d.Folder);        
      myContext.LoadOptions = loadOptions;        
      // Make sure ObjectTracking is turned on        
      myContext.ObjectTrackingEnabled = true;        
      // Get Document from context matching input id        
      Document doc = myContext.GetTable<Document>().Where(d => d.Image_ID == id).ToList().FirstOrDefault();      
      if(doc!=null) {        
        // Mark matching reject reason on document        
        doc.ReasonForRejection = rejReason;        
        // Resubmit table changes        
        myContext.SubmitChanges(); // <-- "Runtime Exception: Row not found or changed."              

    Wednesday, May 3, 2017 1:58 AM

All replies

  • You must be using a third party provider for MS-Access for Entity Framework as Entity Framework does not natively support any version of MS-Access. If this is the case you should be asking the owner of the provider.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Wednesday, May 3, 2017 2:12 AM