3 Replies Latest reply on May 3, 2012 4:37 AM by vangelo-esristaff

    Quirky row behavior when created by search loop

    MCederholm
      I've noticed that row objects tend not to like to travel outside the scope of a search loop, even if the unique option is set.  For example, this code works OK:

         foreach (Row r in tab.Search("*", "", RowInstance.Unique))
         {
          this.Manipulate(r);
          tab.Update(r);
          break;
         }


      Whereas this can crash with a protected memory violation:

         Row row = null;
         foreach (Row r in tab.Search("*", "", RowInstance.Unique))
         {
          row = r;
          break;
         }
         if (row != null)
         {
          this.Manipulate(row);
          tab.Update(row);
         }


      This seems to go against common programming sense, but obviously code design can accommodate this.