InsertRow on Cursor returns error after stopping an EditOperation and Start a new one

4879
14
03-02-2011 01:15 AM
karinweixler
New Contributor II
Hello,
i am trying to migrate Code from AG 9.3 with VS 2005 to AG 10 with VS 2010. In AG 10 i have the following Problem:
'I create a reference to a FeatureTable and Cursor: (this is done outside of the edit session)

FLSTSLnkTable = DBConnection.newpGDBCon.GetFeatureTable("w_Lnk_FLS_TS")
FLSTSLnkCursor = FLSTSLnkTable.Insert(False)

'After that I start the EditSession and an Editoperation:

aoiWorkspaceEdit.StartEditing(True)
aoiWorkspaceEdit.StartEditOperation()

'in this EditOperation i use the InsertRow into the FeatureTable via the cursor and rowbuffer:

Dim myRowBuffer As IRowBuffer
myRowBuffer = FLSLnkTable.CreateRowBuffer
Dim myRow As IRow
myRow = myRowBuffer
Try
    With myRow
         .Value(.Fields.FindField(LnkFLSIdName)) = FeatFeldId
         .Value(.Fields.FindField(LnkSonstIdName)) = Me.ID
         .Value(.Fields.FindField("Flaechenanteil")) = myIntersectArea / 10000
    End With
    FLSLnkCursor.InsertRow(myRowBuffer)
Catch ex As Exception
    MsgBox(ex.Message, MsgBoxStyle.Critical)
    Exit Sub
End Try

'then i stop the edit operation:

aoiWorkspaceEdit.StopEditOperation()

'after that i start a new EditOperation:

aoiWorkspaceEdit.StartEditOperation()

'and then i try to insert another row into the FeatureTable via the cursor and rowbuffer:
and here i get the following error when it comes to the line "FLSLnkCursor.InsertRow(myRowBuffer)":
"The cursor has been invalidated because the edit operation has stopped."

In ArcGIS 9.3 this worked fine. Is there a change in which order i do the reference to the objects in ArcGIS 10? Does someone have a hint how to deal with this error?
Thanks in advance.

Greetings Karin
0 Kudos
14 Replies
karinweixler
New Contributor II
Well, I tried it like you and put the Table (which comes from a PGDB) into the map and make the reference to the table from the standalonetablecollection. Same result --> the HRESULT E_FAIL. Have you tried it with a table which has relations to other tables or featureclasses?
0 Kudos
NeilClemmons
Regular Contributor III
Yes, I just tried it on a table that had both a table join and a relate and it worked fine.  It shouldn't matter though because the ITable reference returned by IStandAloneTable.Table is a reference to the actual table in the geodatabase, which will not be aware of any joins or relates.  If you want, you can attach the geodatabase you're using and I'll try to run my code against your data.
0 Kudos
karinweixler
New Contributor II
Dear Neil, I have attachet the PGDB. You could try it with the table 'w_Lnk_FLS_TS'. This table has a relation to the FC 'w_Dat_Teilschlag' (Id_Teilschlag - ObjectId) and a relation to the FC 'w_Dat_Flurstueck' (Id_Flurstueck - ObjectId). Tank you for your great help!
0 Kudos
NeilClemmons
Regular Contributor III
I haven't had much time to look at this but when I try to add a new record to the table using the ArcMap Editor I get an error saying there must be a record in a related table.  I tried using an ObjectId from the related feature class and still got the same error.  Are you able to add records to this table in ArcMap?  If so, do you still get the error using those same attribute values in your code?
0 Kudos
karinweixler
New Contributor II
I tried to add a new record in ArcMap during a Editsession to the Table, and I also get the error, that there must be a related ObjectId in the related FC, even if i take an ObjectId which is in both of the tables. So i guess ArcMap has a problem with relation done in ACCESS?! This doesen't sound very nice. Is this a known constraint in ArcMap or a bug? Thanks a lot for your time and help!
0 Kudos