MCederholm

Quirky row behavior when created by search loop

Discussion created by MCederholm on May 1, 2012
Latest reply on May 3, 2012 by vangelo-esristaff
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.

Outcomes