Insert a new row in a featureclass, which has relationship defined on the featureclas

123
4
06-09-2011 08:32 AM
New Contributor
Hi All,

I have a featureclass and in which relationsihps are defined. when i insert rows i am getting an error.
Can someone please help me with a sample code on 'How to insert rows in featureclass that has relationships defined'.

I am using ArcEditor 9.3 and visual studio 2010(C#).

Thanks in advance.

Regards,
Srinivasa.
Reply
0 Kudos
4 Replies
New Contributor
Hi All,

I have a featureclass and in which relationsihps are defined. when i insert rows i am getting an error.
Can someone please help me with a sample code on 'How to insert rows in featureclass that has relationships defined'.

I am using ArcEditor 9.3 and visual studio 2010(C#).

Thanks in advance.

Regards,
Srinivasa.


Can you post your code and Error description?
As I understood your query, are you trying to create new features in a Feature class where that class has some relationships with some other either Feature classes or Standalone tables?

Did you locate where exactly you are getting the error?
Reply
0 Kudos
New Contributor
Can you post your code and Error description?
As I understood your query, are you trying to create new features in a Feature class where that class has some relationships with some other either Feature classes or Standalone tables?

Did you locate where exactly you are getting the error?


Hi Syamarth,

Thanks for you reply.

Below is the code.

IVersionedWorkspace versionedWorkspace = (IVersionedWorkspace)workspace;
                IVersion qaVersion = versionedWorkspace.FindVersion("APATEL.NEW WO");

                ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = ((IFeatureWorkspace)versionedWorkspace).OpenFeatureClass("NE.EQUIPMENT");

               
                IMultiuserWorkspaceEdit muWorkspaceEdit = (IMultiuserWorkspaceEdit)qaVersion;
                IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)qaVersion;

                workspaceEdit.StartEdition(false);
                workspaceEdit.StartEditOperation();

                muWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);

                IFeatureBuffer newFeature = featureClass.CreateFeatureBuffer();
                newFeature.Shape = oldFeature.ShapeCopy;
                featureClass.Insert(false);  //geetting exception here "Objects in this class cannot be updated outside an edit session [NE.EQUIPMENT]"

                workspaceEdit.StopEditing(true);


I am getting error("Objects in this class cannot be updated outside an edit session [NE.EQUIPMENT]"
) at featureClass.Insert(false).

If the same code runs on a featureclass that doesn't have any realtionship, its working fine.

Thanks in advance.

Regards,
Srinivasa.
Reply
0 Kudos
Regular Contributor II
I too have had the same problem (was dealing with that Monday.)  In my case I had an unversioned featuredataset with featureclasses, one of which had a 1:n forward relationship class.  The problem only happened editing the origin featureclass using an update cursor (class happened to be anno.)  I fixed it by setting the esriMultiuserEditSessionMode to non-versioned and getting rid of the operation.  The strange thing is it shouldn't work at all (IMHO.)  the SupportsMultiuserEditSessionMode(esriMESMVersioned) returned true even if the data was not versioned.  The documentation says that if the data is versioned then it doesn't support non-versioned editing but I was expecting the other way around also...  I am not sure what the implications of doing versioned editing on non-versioned data but I suspect it is not too good.  Another developer made the same mistake in C++ (IWorkspaceEdit.StartEditing) and ended up creating a bunch of rows in the sde states and states_lineage tables with no way to compress them (compress just didn't remove them.)
Reply
0 Kudos
New Contributor
Hi All,

Can some please help me on 'How to insert new rows in a featureclass that has relationship defined'?

Thanks in Advnace.

Regards,
Srinivasa.
Reply
0 Kudos