Select to view content in your preferred language

Error while updating Feature value of a feature class

2598
3
07-11-2013 01:34 AM
IshanKaushik
Emerging Contributor
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

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 --

                   
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 --

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 ////
0 Kudos
3 Replies
DuncanHornby
MVP Notable Contributor
Sounds like the source workspace is corrupt.

Is your workspace an Access database or a personal geodatabase? I would use arcmap to create a new geodatabase then copy your data into it to ensure the GDB_ tables exist.
0 Kudos
IshanKaushik
Emerging Contributor
My source workspace is personal geodatabase.
I am tring following code so that i can delete particular feature value in a feature class .
0 Kudos
IshanKaushik
Emerging Contributor
I tried coping geodatabase to arcMap to see if feature class exists ,
Yes its has same name and has been displayed as a layer in Table OF Content.
0 Kudos