solsberg

Unable to update shapefile attributes in c++

Discussion created by solsberg on Jun 21, 2012
I am having trouble updating the attributes in a shapefile using ArcObjects with c++ - nothing seems to get written through to the shapefile, in fact the modify dates of the files are not even updated.
If I write the equivalent code in a C# application then it works as expected. Similarly, my c++ code works fine with a file geodatabase workspace.
I have also found that in c++ if I perform the operation without setting up the enclosing edit session then it also works OK.

Any ideas as to what might be going on?
Should I not be using an edit session for shapefiles (even though this does still work in .NET)?

Thanks
Simon Olsberg


IWorkspaceFactoryPtr ipWSF;
ipWSF.CreateInstance(CLSID_ShapefileWorkspaceFactory);

IWorkspacePtr ipWorkspace;
ipWSF->OpenFromFile(CComBSTR(shapefileDirectory), 0, &ipWorkspace);

IFeatureWorkspacePtr ipFWS(ipWorkspace);
IFeatureClassPtr ipFeatureClass;
ipFWS->OpenFeatureClass(CComBSTR(shapefileName), &ipFeatureClass);

IFeaturePtr ipFeature;
ipFeatureClass->GetFeature(id, &ipFeature);

IWorkspaceEditPtr workspaceEdit(ipWorkspace);

workspaceEdit->StartEditing(false);
workspaceEdit->StartEditOperation();

ipFeature->put_Value(colIndex, CComVariant(intValue));
ipFeature->Store();

workspaceEdit->StopEditOperation();
workspaceEdit->StopEditing(true);

Outcomes