How to add feature with related features

07-16-2013 06:18 AM
New Contributor
The problem is solved. It's all because of GUID format

Hello, everyone.
I need to programmatically add object with geometry to table. type of geometry may be different, so main data is stored in the table and geometry is stored in related feature class, related on Guid field.

To add data i use code like this:

  IFeatureLayer lyr = MapHelper.FindLayer(Properties.Settings.Default.LineStatementsLayer) as IFeatureLayer;
                if (lyr != null)
                    geomfeature = lyr.FeatureClass.CreateFeature();
                    geomfeature.Shape = wrapper.Geometry;
                    int ind = geomfeature.Fields.FindField("GUID");
                    if (ind > 0)

                        geomfeature.Value[ind] = guid;




            ITable table = MapHelper.FindTable(Properties.Settings.Default.StatementsTable);
            if (table != null)
                feature = table.CreateRow();
                int ind = feature.Fields.FindField("LIFE_STATE");
                if (ind > 0)
                    feature.Value[ind] =1;
                ind = feature.Fields.FindField("GUID");
                if (ind > 0)

when executing this code? i always get exception "The workspace is not connected" on line
"geomfeature.Value[ind] = guid;"

if i change order of adding row and geometry exception is beeing throwed on line


However setting of ShapeField and Life_State field doesn't throw any exception/ I think the cause of this problem is corrupting of referential integrity in SDE with relationclasses. Can you recommend  me a proper way to solve this problem?
0 Kudos
0 Replies