English

Error: Insufficient permissions

Error Message

ArcObjects code that edits features within a geodatabase runs against a personal geodatabase but returns the following error when run against a versioned feature class in an SDE geodatabase:

Insufficient permissions

The error message may be appended with the following information:
[<database.><user>.<feature class name>]
[STATE_ID=####]

Where the database is the current database on supported DBMSs, the user is the owner of the feature class and ### is the State ID.

Cause

You must use an edit operation when editing versioned SDE data.

Solution or Workaround

This sample code shows how to add an edit operation to your code when using the IEditor interface.

Code:
Sub addPointToFirstLayer()
Dim pMap As IMap
Dim pMxDoc As IMxDocument
Dim pFeatLyr As IGeoFeatureLayer
Dim pFClass As IFeatureClass
Dim pDS As IDataset
Dim pWor As IWorkspace
Dim pEditor As IEditor
Dim pID As New UID
Dim pfeat As IFeature
Dim pPoint As IPoint

pID = "esriCore.Editor"
Set pEditor = Application.FindExtensionByCLSID(pID)
Set pMxDoc = ThisDocument
Set pMap = pMxDoc.FocusMap

Set pFeatLyr = pMap.Layer(0)
Set pFClass = pFeatLyr.FeatureClass
Set pDS = pFClass
Set pWor = pDS.Workspace

pEditor.StartEditing pWor
pEditor.StartOperation
Set pfeat = pFClass.CreateFeature
Set pPoint = New Point
pPoint.X = 2212000
pPoint.Y = 397000
Set pfeat.Shape = pPoint
pfeat.Store
pEditor.StopOperation "Add Point Feature"
pEditor.StopEditing True
End Sub


This sample code shows how to add an edit operation to your code when using the IWorkspaceEdit interface.

Code:
Sub addPointToFeatureClass()
'Assume we have a reference to IWorkspace called pWor and a feature class called pFClass
Dim pfeat As IFeature
Dim pPoint As IPoint

Set pEditWS = pWor
pEditWS.StartEditing True
pEditWS.StartEditOperation
Set pfeat = pFClass.CreateFeature
Set pPoint = New Point
pPoint.X = -59.05
pPoint.Y = 51.11
Set pfeat.Shape = pPoint
pfeat.Store
pEditWS.StopEditOperation
pEditWS.StopEditing True
End Sub