1

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;
                }

2 Answers 2

1

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");
}
0

Check your where clause.

Here's an example that will get all you features in your feature class then test the geometry.

            IFeatureLayer ilayer = (IFeatureLayer)ArcMap.Document.FocusMap.get_Layer(0);

            IQueryFilter queryFilterlast = new QueryFilterClass();

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

            queryFilterlast.WhereClause = null;
            pFCursor = pFc.Search(queryFilterlast, false);
            pF = pFCursor.NextFeature();

            while (pF != null && pF.Shape != null && pF.Shape.IsEmpty == false ) {
                if (pFc.ShapeType == esriGeometryType.esriGeometryLine || pFc.ShapeType == esriGeometryType.esriGeometryPolyline) {
                    ICurve curveForLength = (ICurve)pF.Shape;
                    System.Diagnostics.Debug.WriteLine(curveForLength.Length.ToString());

                }
                pF = pFCursor.NextFeature();
            }

Using the null query filter will return all of the features in your featureclass. You can then test the shape field for a value , then get the value for length using the ICurve interface.

ESRI has a similar vba example here: http://support.esri.com/cn/knowledgebase/techarticles/detail/19145

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.