Exception: Objects in this class cannot be updated outside an edit session

المشرف العام

Administrator
طاقم الإدارة
I meet a Exception. When the code run at

pWorkSpaceEdit.StartEditing(true);then the exception was threw and Visual Studio showed a word "Objects in this class cannot be updated outside an edit session" to me.

the code is followed.

public static bool InsertFeature(List fieldname, List fieldvalue, IGeometry geometry, string Featurename) { try { SDEHelper.OpenSdeWorkSpace(); IWorkspaceEdit pWorkSpaceEdit = (IWorkspaceEdit)SDEHelper.pWorkSpace; IFeatureClass pFeaClass = SDEHelper.GetFeatureClassByName(Featurename); IFeatureBuffer pFeaBuffer = pFeaClass.CreateFeatureBuffer(); IFeatureCursor pFeaCur = pFeaClass.Insert(false); pWorkSpaceEdit.StartEditing(true); pWorkSpaceEdit.StartEditOperation(); if (geometry != null) { pFeaBuffer.Shape = geometry; } for (int f = 0; f < fieldname.Count; f++) { if (!string.IsNullOrEmpty(fieldvalue[f])) { pFeaBuffer.set_Value(pFeaBuffer.Fields.FindField(fieldname[f]), fieldvalue[f]); } } int flag = (int)pFeaCur.InsertFeature(pFeaBuffer); pFeaCur.Flush(); pWorkSpaceEdit.StopEditOperation(); pWorkSpaceEdit.StopEditing(true); } catch (Exception e) { throw e; } return true; }The featureclass from ArcSDE is right. Why am i getting this error even if i have started the edit operation on workspace.



أكثر...
 
أعلى