IMapServer3 ms = (IMapServer3)this.mapServerDataAccess; IDataset fc = this.mapServerDataAccess.GetDataSource(ms.DefaultMapName, 0) as IDataset; IFeatureWorkspace workspace = (IFeatureWorkspace)fc.Workspace; IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)fc.Workspace; workspaceEdit.StartEditing(false); workspaceEdit.StartEditOperation(); IFeatureClass fClass = workspace.OpenFeatureClass(layer); IFeature feature = fClass.CreateFeature(); // Removed lines where assigning data to the feature... feature.Store(); workspaceEdit.StopEditOperation(); workspaceEdit.StopEditing(true);
Please note that if your featureclass contains attachments and you're in SDE, you'll have to use an additional ArcObject: IMultiuserWorkspaceEdit
This error message is associated with a number of possible causes. Here are two reasons:
1- If your SDE data is not versioned. In this case, simply register your data as versioned using ArcCatalog.
2- If you connected to your SDE geodatabase programmatically using IPropertySet, and the server name used is an alias name instead of the original server name. Use the IPropertySet.GetAll properties() method to investigate the exact names of all the properties you would need to supply to the IPropertySet. It is easier to simply connect via the SDE connection file.
For detailed information about creating features and Managing Edit Sessions using ArcObjects, please view the following documentation in the ArcObjects Help:
Creating Features
Managing Editing Sessions and Edit Operations