Quantcast
Channel: Forums - ArcObjects SDKs
Viewing all articles
Browse latest Browse all 1374

Error while updating Feature value of a feature class

$
0
0
Hi,

I am trying to update my feature class via IWorkspace.edit session by using ICursor.update methord .
Following is what i am trying to do

Code:

while ((row = cursor.nextRow()) != null){
        IWorkspace iworkspace = workspace;
        IWorkspaceEdit iworkedit = (IWorkspaceEdit) iworkspace;
            iworkedit.startEditing(true);
        iworkedit.startEditOperation();
        int typeFieldIndex = className2.findField(fieldName);
        IQueryFilter queryFilter = new QueryFilter();
        queryFilter.setWhereClause(fieldName+" = "+ row.getValue(fieldName2));
        // Create a Search cursor.
        IFeatureCursor searchCursor = (IFeatureCursor) className2.update(queryFilter, false);
        // Edit the features matching the query.
        IFeature feature = null;
        try
              {
              while ((feature = searchCursor.nextFeature()) != null)
            {
                feature.setValue(typeFieldIndex, null);
                searchCursor.updateFeature(feature);
                }       
            }
              catch (Exception comExc)
              {
                comExc.printStackTrace();
                // Handle any errors that might occur on NextFeature().
              }
              iworkedit.stopEditOperation();
                iworkedit.stopEditing(true);
        }

While running the code i get following error

Error: AutomationException: The Microsoft Jet database engine cannot find the input table or query 'GDB_ReplicaChanges'. Make sure it exists and that its name is spelled correctly.
And point out to following line --
IFeatureCursor searchCursor = (IFeatureCursor) className2.update(queryFilter, false);

What is the issue here , according to me the classname2 feature class exists and name is spelled dynamically so no issue of "spelled correctly", other than that what is wrong here.


For same problem i tried a different approach -
I initialised edit session as follows at beginning of program --

Code:

IWorkspaceFactory workspaceFactory = new AccessWorkspaceFactory();
            IWorkspace iworkspace = new Workspace(workspaceFactory.openFromFile(locatePgdb, 0));
            IWorkspaceEdit iworkedit = (IWorkspaceEdit) iworkspace;
            iworkedit.startEditing(true);
            iworkedit.startEditOperation();

And then i passed my query like this --

Code:

int typeFieldIndex = className2.findField(fieldName);
IQueryFilter queryFilter = new QueryFilter();
queryFilter.setWhereClause(fieldName+" = "+ row.getValue(fieldName2));
 // Create a Search cursor.
IFeatureCursor searchCursor = (IFeatureCursor) className2.update(queryFilter, true);
// Edit the features matching the query.
IFeature feature = null;
try
 {
while ((feature = searchCursor.nextFeature()) != null)
{
feature.setValue(typeFieldIndex, null);
searchCursor.updateFeature(feature);
feature.store();
}       
}
catch (Exception comExc)
 {                                                                                                                  comExc.printStackTrace();
// Handle any errors that might occur on NextFeature().
 }

Then i am having error of --
Objects in this class cannot be updated outside an edit session [Service]

Kindly provide me wats wrong being done here ////

Viewing all articles
Browse latest Browse all 1374

Trending Articles