[GIS] Get Features from ifeatureclass

arcgis-desktoparcmaparcobjects

I am facing the issue while I am trying to get all the features back in 'Attribute Table'.
What I am doing is.

  1. Selected the layer from Map
  2. Performs my Edits on few features (changing filed values)

(After I perform my changes I take

  1. While I again want to get all my features back I am getting error.

Exception from HRESULT: 0x8004151C

I tried with below code :

In both the case it's giving error.

///////1st//////////

IFeatureClass pFc = ilayer.FeatureClass;
IFeatureCursor pFCursor;
IFeature pF;

queryFilterlast.WhereClause = "SHAPE.LEN IS NOT NULL";
pFCursor = pFc.Search(queryFilterlast, false);
pF = pFCursor.NextFeature();

while (pF != null)
{
   pF = pFCursor.NextFeature();
}

/////////2nd//////////////

//initialize queryfilter
                queryFilterlast.SubFields = "*";
                queryFilterlast.WhereClause = "SHAPE.LEN IS NOT NULL";


                //Using a query filter to search a feature class:
                featureselectionlast.SelectFeatures(queryFilterlast, esriSelectionResultEnum.esriSelectionResultNew, false);

                //output features assign into featureset
                featuresetlast = featureselectionlast.SelectionSet;

                if (featuresetlast.Count != 0)
                {
                    featuresetlast.Search(null, false, out icursor);
                    //featureCursor = icursor as IFeatureCursor;
                    IFeatureCursor featureCursorL = icursor as IFeatureCursor;

                    //Get the output features 
                    IFeature feature = featureCursorL.NextFeature();

                    //Loop through output features
                    while (feature != null)
                    {
                        feature = featureCursorL.NextFeature();
                    }
                    //Release the cursor
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursorL);
                    featureCursorL = null;
                }

Best Answer

Firstly your error message is 'FDO_E_SE_NO_PERMISSIONS'.. read more about ArcObjects Error Codes here and a post about it here for what that's worth. This is an SDE error, ensure your credentials are valid for querying/editing that table.

If your data is versioned you need to bracket all modifications in an edit operation during an edit session.. so it might be necessary to either disable the tool until the user has started editing or start/stop editing within the tool itself.

To check if the session is editing use the IEditor interface:

IEditor m_editor = app.FindExtensionByName("ESRI Object Editor") as IEditor;
if (m_editor.EditState == esriEditState.esriStateEditing) 
{
    m_editor.StartOperation();
    // do your operation
    m_editor.StopOperation("Your undo text");
}
Related Question