AnsweredAssumed Answered

deleting a feature HRESULT E_FAIL error

Question asked by yellow_rose on Jul 31, 2015
Latest reply on Dec 1, 2015 by SEria-esristaff

I am trying to delete features from a feature class but i always get this error

"Error HRESULT E_FAIL has been returned from a call to a COM component."

at this line feature.Delete();

 

Here is my code:

private void DeleteRecordsFromStandardDBFeatureClass()

        {

            try

                {

                    ESRI.ArcGIS.Geodatabase.IFeatureClass destinationFeatureClass = Globals.GlobalsInstance.StandardDB.GetFeatureWorkSpaceOfDataSource().OpenFeatureClass(m_tableName);

                     ESRI.ArcGIS.Geodatabase.IFeatureCursor searchCursor = destinationFeatureClass.Search(null, false);

                    // Delete the retrieved features.

                    ESRI.ArcGIS.Geodatabase.IFeature feature = null;

                    while ((feature = searchCursor.NextFeature()) != null)

                    {

                        feature.Delete();

                    }

                }

                catch (Exception ex)

                {

                    Logger.LoggerInstance.LogError(ex.Message, DateTime.Now, "DeleteRecordsFromStandardDBFeatureClass", "MigrationFeatureClass", m_tableName);

                    throw new Exception(ex.Message);

                }

           

        }

Outcomes