suneelhere

Unable to update a row of a featureclass table

Discussion created by suneelhere on Jun 13, 2011
Latest reply on Jun 29, 2011 by jeffhamblin
Here is my code: This is executing but the table is not updating.

ESRI.ArcGIS.esriSystem.IPropertySet propertySet = new
             ESRI.ArcGIS.esriSystem.PropertySetClass();

            propertySet.SetProperty("SERVER", "172.16.8.148");
            propertySet.SetProperty("INSTANCE", "ESRI_SDE");
            propertySet.SetProperty("DATABASE", "ARCGIS_SCADA");
            propertySet.SetProperty("USER", "sde");
            propertySet.SetProperty("PASSWORD", "smartgrid");
            propertySet.SetProperty("VERSION", "SDE.DEFAULT");
            propertySet.SetProperty("AUTHENTICATION_MODE", "DBMS");
            //propertySet.SetProperty("DATABASE","Connection to 172.16.8.148.sde/SDE.TEST");

            IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass();
            IWorkspace workspace = workspaceFactory.Open(propertySet, 0);
            try
            {

                //Cast to IFeatureWorkspace.
                IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;               
                IFeatureClass featureClass =           featureWorkspace.OpenFeatureClass("SDE.SCADA_NEW_CB");


                // Find the index of the field to edit.
                int typeFieldIndex = featureClass.FindField("STATE");

                // Cast the workspace to an IWorkspaceEdit and start an edit session.
                IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;
                workspaceEdit.StartEditing(true);

                // Start an edit operation and create a cursor.
                workspaceEdit.StartEditOperation();

                IQueryFilter queryFilter = new QueryFilterClass();
                queryFilter.WhereClause = "OBJ_NAME='1A-1'"; //"U" = domain value for Utility
                queryFilter.SubFields = "STATE";

                // Create a Search cursor.
                IFeatureCursor UpdateCursor = featureClass.Search(queryFilter, false);

                // Edit the features matching the query.
                IFeature feature = null;

                while ((feature = UpdateCursor.NextFeature()) != null)
                    {
                        feature.set_Value(typeFieldIndex,0);
                        UpdateCursor.UpdateFeature(feature);
                        feature.Store();
                    }
               

                // Since the edit operation is ending, release the cursor.
                Marshal.ReleaseComObject(UpdateCursor);

                // Stop the edit operation.
                workspaceEdit.StopEditOperation();

                // Stop the edit session.
                workspaceEdit.StopEditing(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }

Outcomes