When working with simple features and edit sessions in an Engine application, it's recommended that a search cursor be used to take advantage of batched updates in edit operations. Outside of edit sessions, an update cursor allows performance and error handling advantages. With complex features, on the other hand, update calls are overridden by the features' custom behavior, meaning that the feature's store method will be called even if an update cursor is used.
This post has been very helpful. I had the same error but not for the same reason. I found two ways to successfully edit the attributes and would like to know which way is better.This one uses Update: _SFRMPSelectionSet.Update(null, false, out pCursor); if (pCursor == null) { return false; } pRow = pCursor.NextRow(); while (pRow != null) { foreach (var pair in dictFieldsValues) { fldIndex = _SFRMPFeatureLayer.FeatureClass.Fields.FindField(pair.Key); objectValue = pair.Value; pRow.set_Value(fldIndex, objectValue); } pCursor.UpdateRow(pRow); pRow = pCursor.NextRow();This one uses Store: _SFRMPSelectionSet.Search(null, false, out pCursor); if (pCursor == null) {return false; } pRow = pCursor.NextRow(); while (pRow != null) { foreach (var pair in dictFieldsValues) { fldIndex = _SFRMPFeatureLayer.FeatureClass.Fields.FindField(pair.Key); objectValue = pair.Value; pRow.set_Value(fldIndex, objectValue); } pRow.Store(); pRow = pCursor.NextRow();Thank you so much.
_SFRMPSelectionSet.Update(null, false, out pCursor); if (pCursor == null) { return false; } pRow = pCursor.NextRow(); while (pRow != null) { foreach (var pair in dictFieldsValues) { fldIndex = _SFRMPFeatureLayer.FeatureClass.Fields.FindField(pair.Key); objectValue = pair.Value; pRow.set_Value(fldIndex, objectValue); } pCursor.UpdateRow(pRow); pRow = pCursor.NextRow();
_SFRMPSelectionSet.Search(null, false, out pCursor); if (pCursor == null) {return false; } pRow = pCursor.NextRow(); while (pRow != null) { foreach (var pair in dictFieldsValues) { fldIndex = _SFRMPFeatureLayer.FeatureClass.Fields.FindField(pair.Key); objectValue = pair.Value; pRow.set_Value(fldIndex, objectValue); } pRow.Store(); pRow = pCursor.NextRow();
okI am not sure what we are arguing or discussing about.I know it is illegal. My question was, why ESRI provides (recyclable option) on update cursor if it is not going to work.That was my questionForget about this thread, and thank you for creating all that noise with no answer.I will create another post
Ghassan,There are many ways to do updates. Are you using store on the feature or are you calling updatefeature on the featurecursor? Are you inside an edit session (on the editor extension or on IWorkspaceEdit) or not in an edit session? If in an edit session are you in an edit operation? Are you using com release on each feature after the edit is done? Have you place the featureclasses in load only mode? Is the data in a enterprise database or a file database? If in a enterprise database, is the data versioned? You may be running out of memory if you don't release any of the features as you go along. You could be filling up user allocated space on the database also.
That error matches exactly what the documentation says is illegal to maintain, that I quoted earlier.
FDO_E_CANNOT_STORE_RECYCLED_ROW_IN_EDIT_SESSION
What kind of error message would I get?
Where did you read that it is prevented in 10.1? The docs suggest that you do not modify features returned by a recycling cursor.
I know recycling should not be used when we do update, and actually it was permitted on 9.3 in spite of being undesirable, and it is totally prevented on 10.1
The recycling parameter controls row object allocation behavior. Recycling cursors rehydrate a single feature object on each fetch and can be used to optimize read-only access, for example, when drawing. It is illegal to maintain a reference on a feature object returned by a recycling cursor across multiple calls to NextFeature on the cursor. Features returned by a recycling cursor should not be modified. Non-recycling cursors return a separate feature object on each fetch. The features returned by a non-recycling cursor may be modified and stored with polymorphic behavior.
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.