Error editing a blob field in ArcGIS Engine
Posted
by Victor Grigoriu
on Stack Overflow
See other posts from Stack Overflow
or by Victor Grigoriu
Published on 2009-11-05T15:53:04Z
Indexed on
2010/03/18
13:21 UTC
Read the original article
Hit count: 735
I have a GIS layer backed by a MSSQL db. The features on the layer have, say, one field of type esriFieldTypeString and one of type esriFieldTypeBlob. I can edit the string field just fine, but, when I try to edit a blob, StopEditOperation() throws a very generic exception (message: "Error HRESULT E_FAIL has been returned from a call to a COM component.", error code: -2147467259). I couldn't find anything related in the server log. Does anyone have any idea what's going on?
IServerContext serverContext = GetServerContext(agsConn, serviceName);
ILayer layer = GetILayer(layerName, serverContext);
IWorkspace workspace = GetIWorkspace(layer);
var feature = GetIFeature(objectId, workspace, layer);
var workspaceEdit = (IWorkspaceEdit)workspace;
workspaceEdit.StartEditing(false);
workspaceEdit.StartEditOperation();
var index = feature.Fields.FindField(featureDetailName);
IField field = feature.Fields.get_Field(index);
byte[] byteArray = {1, 2, 3};
MemoryBlobStream blob = new MemoryBlobStream();
((IMemoryBlobStreamVariant)blob).ImportFromVariant(byteArray);
if (field.CheckValue(blob))
{
feature.set_Value(index, blob);
}
feature.Store();
workspaceEdit.StopEditOperation();
workspaceEdit.StopEditing(true);
serverContext.RemoveAll();
serverContext.ReleaseContext();
© Stack Overflow or respective owner