ishan00kaushik

Objects in this class cannot be updated outside an edit session

Discussion created by ishan00kaushik on Jul 20, 2013
Latest reply on Jul 21, 2013 by ishan00kaushik
HI,

I am trying to delete selected features of a feature class . FOllowing is what i am trying to edit a PGDB --

 private void openFromFile_pGDB_Workspace(String inPGDB)throws Exception{
  IWorkspaceFactory workspaceFactory = new AccessWorkspaceFactory();
  IWorkspace workspace = new Workspace(workspaceFactory.openFromFile(inPGDB, 0));
  IFeatureWorkspace ifw = (IFeatureWorkspace) workspace;
  IFeatureClass ifetclass =  ifw.openFeatureClass("CPAnode");
  IWorkspaceEdit iwe = (IWorkspaceEdit)workspace;
  iwe.startEditing(true);
  iwe.startEditOperation();
     IFeatureCursor ifc = ifetclass.search(null, true);
     int field = ifc.findField("CONSTRUCTIONSTATUS");
     System.out.println("CONSTRUCTIONSTATUS :"+field);
     IFeature iff = ifc.nextFeature();
     while((iff = ifc.nextFeature()) != null)
     {
      
         iff.setValue(field, null);
         iff.store();
         
     }
  iwe.stopEditOperation();
  iwe.stopEditing(true);
    
     
   }


This if what i am getting in console ---

CONSTRUCTIONSTATUS :5
AutomationException: 0x80041354 - Objects in this class cannot be updated outside an edit session [CPAnode] in 'ESRI GeoDatabase'
at com.esri.arcgis.geodatabase.SimpleJunctionFeature.store(Unknown Source)
at avineon.Delete.openFromFile_pGDB_Workspace(Delete.java:137)
at avineon.Delete.main(Delete.java:85)
Error: AutomationException: Objects in this class cannot be updated outside an edit session [CPAnode]
Sample failed.  Exiting...


I am getting a hard time to edit these feature , if this is not the correct way to edit features than what else should i try.

Outcomes