AnsweredAssumed Answered

"The requested operation is invalid on a closed state" error

Question asked by moje03 on Apr 1, 2016
Latest reply on Apr 3, 2016 by moje03

Hello all,

 

I have an ArcObjects add-in that works fine on the company server with and ArcSDE SQL Server database, but on the client's network, when the app attempts to save a new point, or changes to an existing point, it gets the following error: "The requested operation is invalid on a closed state. [StellarRoutes.DBO.Commercial_Bin_Points] State_ID = 14"

 

Here is the code:

Protected Function SaveContChanges()

 

        Dim pDataset As ESRI.ArcGIS.Geodatabase.IDataset
        Dim tTable As ESRI.ArcGIS.Geodatabase.Table
        Dim pfeatWorksspace As ESRI.ArcGIS.Geodatabase.IFeatureWorkspace
        Dim m_pqueryfilter As ESRI.ArcGIS.Geodatabase.QueryFilter
        Dim pcur As ESRI.ArcGIS.Geodatabase.ICursor
        Dim prow As ESRI.ArcGIS.Geodatabase.IRow
        Try
            StartEditSession()

 

            m_pLayer = GetLayer(ComboValue)
            pFLayer = m_pLayer
            pDataset = pFLayer

 

            pfeatWorksspace = pDataset.Workspace

 

            tTable = pfeatWorksspace.OpenTable("DBO.Commercial_Bin_Points")

 

            m_pqueryfilter = New ESRI.ArcGIS.Geodatabase.QueryFilter
            m_pqueryfilter.WhereClause = "Bin_ID = '" & txtBinID.Text & "'"

 

            pcur = tTable.Search(m_pqueryfilter, False)
            prow = pcur.NextRow

 

            prow.Value(pcur.FindField("ContSize_ID")) = cboContSize.SelectedValue
            prow.Value(pcur.FindField("ContColor_ID")) = cboContColor.SelectedValue
            prow.Value(pcur.FindField("Route")) = cboRoutes.SelectedValue
            prow.Value(pcur.FindField("ServiceType_ID")) = cboServiceType.SelectedValue
            prow.Value(pcur.FindField("PickupType_ID")) = cboPickupType.SelectedValue
            prow.Value(pcur.FindField("Notes")) = txtBinNotes.Text
            prow.Value(pcur.FindField("X")) = Val(txtX.Text)
            prow.Value(pcur.FindField("Y")) = Val(txtY.Text)
            prow.Value(pcur.FindField("ADDRESS")) = cboAddress.Text
            prow.Store()
            StopEditSession()

 

        Catch exception As Exception
            MsgBox("Error: " & exception.Message)
        End Try
End Function

 

Public Shared Sub StartEditSession()
    Dim pDataset As ESRI.ArcGIS.Geodatabase.IDataset
    Dim editor As ESRI.ArcGIS.Editor.IEditor
    editor = My.ArcMap.Application.FindExtensionByName("esriEditor.Editor")

 

    '    If ComboValue Is Nothing Then
    '    MsgBox("Please Select the edit feature in the combobox!.")
    '    Exit Sub
    '    End If

 

    m_pLayer = GetLayer(ComboValue)
    pFLayer = m_pLayer
    pDataset = pFLayer

 

    If editor.EditState <> ESRI.ArcGIS.Editor.esriEditState.esriStateEditing Then
        editor.StartEditing(pDataset.Workspace)
        editor.StartOperation()
    End If

 

End Sub

 

Public Shared Sub StopEditSession()
    Dim pDataset As ESRI.ArcGIS.Geodatabase.IDataset = Nothing
    Dim editor As ESRI.ArcGIS.Editor.IEditor
    editor = My.ArcMap.Application.FindExtensionByName("esriEditor.Editor")

 

    m_pLayer = GetLayer(ComboValue)
    pFLayer = m_pLayer
    pDataset = pFLayer

 

    If editor.EditState <> ESRI.ArcGIS.Editor.esriEditState.esriStateNotEditing Then
        Try
            editor.StopOperation("Add/Edit Container")
            editor.StopEditing(True)
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try
    End If
End Sub

 

 

I'm banging my head against the wall here. I can't see why this works on my network and not on the clients.

 

Any help would be very much appreciated.

 

Jeff

Outcomes