Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.


So, I believe I'm getting closer to being able to edit my sde table, however now I'm getting stuck on this line:

Dim updateCursor As ICursor = table2.Update(Nothing, True)

With this error message:

System.Runtime.InteropServices.COMException (0x8004056E): The object cannot be edited using the current edit session mode. [mydatabase.LOADER.mytable]

My code source for the updateCursor is from here:

Update features - Using an update cursor

The table I'm trying to edit is not versioned, I'm unsure of why I can not edit it. Here is my code so far.

Thank you

            Dim server As String = "myserver"
            Dim instance As String = "5151"
            Dim database As String = "sde"
            Dim user As String = "myuser"
            Dim password As String = "mypassword"
            Dim version As String = "SDE.DEFAULT"

            Dim propertySet As IPropertySet = New PropertySetClass()

            propertySet.SetProperty("SERVER", server)

            propertySet.SetProperty("INSTANCE", instance)

            propertySet.SetProperty("DATABASE", database)

            propertySet.SetProperty("USER", user)

            propertySet.SetProperty("PASSWORD", password)

            propertySet.SetProperty("VERSION", Version)

            Dim factoryType As Type = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory")
            Dim workspaceFactory As IWorkspaceFactory = CType(Activator.CreateInstance(factoryType), IWorkspaceFactory)

            ' Cast the workspace to the IWorkspaceEdit2 and IMultiuserWorkspaceEdit interfaces.
                            Dim pSDEFeatWksp As IFeatureWorkspace = workspaceFactory.Open(propertySet, 0)

            Dim table2 As ITable = pSDEFeatWksp.OpenTable("mydatabase.LOADER.mytable")

            Dim workspaceEdit2 As IWorkspaceEdit2 = CType(pSDEFeatWksp, IWorkspaceEdit2)
            Dim muWorkspaceEdit As IMultiuserWorkspaceEdit = CType(pSDEFeatWksp, IMultiuserWorkspaceEdit)

            ' Make sure that non-versioned editing is supported. If not, throw an exception.
            If Not muWorkspaceEdit.SupportsMultiuserEditSessionMode(esriMultiuserEditSessionMode.esriMESMNonVersioned) Then
                Throw New ArgumentException("The workspace does not support non-versioned editing.")
            End If

            ' Start a non-versioned edit session.

            ' Create a ComReleaser for cursor management.
            Using comReleaser As ESRI.ArcGIS.ADF.ComReleaser = New ESRI.ArcGIS.ADF.ComReleaser()

                ' Use ITable.Update to create an update cursor.

                Dim updateCursor As ICursor = table2.Update(Nothing, True) ' <<< ERROR HERE

                ' Find the positions of the fields used to get and set values.

                Dim myfield1 As Integer = table2.FindField("field1")
                Dim myfield2 As Integer = table2.FindField("field2")
                Dim myfield3 As Integer = table2.FindField("field3")
                Dim row As IRow = updateCursor.NextRow()

-----------------Original question--------------------

This is a continuation question from:

Edit SDE table with ArcObjects

share|improve this question
artwork, can you connect to a sde geodatabase using those parameters using arcCatalog? Just make a new .sde conenction file and tryout those parameters. The error is stating that your login is bad. Can you confirm that it is ok? –  George Aug 1 '11 at 15:01
If are sure your user/password combination is OK, I'd take a look at the DATABASE parameter.. what database backend is there? Is it MS SQL? –  Petr Krebs Aug 1 '11 at 15:09
@George see my updated question/Code2, thx! –  artwork21 Aug 1 '11 at 16:08
@Petr Krebs see my updated question/Code2, thx! –  artwork21 Aug 1 '11 at 16:08
@artwork21: Are you using snippet 1 to connect to the database, correct? So you can get to the IWorkspace interface. WorkspaceFactory.Open() will give you a IWorkspace object, which you can, cast to IWorkspaceEdit or IWorkspaceEdit2, without issues. WHat is the error you are experiencing? –  George Aug 2 '11 at 12:26
show 3 more comments

closed as too localized by PolyGeo, Fezter, Chad Cooper, Devdatta Tengshe, R.K. May 1 '13 at 16:09

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.