当前位置: 代码迷 >> GIS >> 关于调用IFeatureClass进行Insert失败有关问题
  详细解决方案

关于调用IFeatureClass进行Insert失败有关问题

热度:407   发布时间:2016-05-05 06:38:28.0
关于调用IFeatureClass进行Insert失败问题

程序简要代码如下:

esriGeoDatabase::IFeatureWorkspacePtr   spFeaWs   =   spWorkspace;
esriGeoDatabase::IWorkspaceEditPtr   spWsEdit   =   spFeaWs;


spWsEdit-> StartEditing(VARIANT_TRUE);
spWsEdit-> StartEditOperation();

esriGeoDatabase::IFeatureClassPtr   spFeatureClass;
spFeaWs-> raw_OpenFeatureClass(sDestTbName.AllocSysString(),&spFeatureClass);

esriGeoDatabase::IFeatureBufferPtr   spFeatureBuf;
esriGeoDatabase::IFeatureCursorPtr   spFeacureCursor;

spFeacureCursor   =   spFeatureClass-> Insert(VARIANT_TRUE);
if   (spFeacureCursor   ==   NULL)  
{
return   FALSE;
}

执行insert时,总是出现错误   “无效的参数量”

请高手给予回答啊,急啊

------解决方案--------------------
帮助中有这么一个例子,你可以看一下

[C#]
public void IFeatureClass__Insert(IFeatureClass featureClass)
{
//get the Workspace from the IDataset interface on the feature class
IDataset dataset = (IDataset)featureClass;
IWorkspace workspace = dataset.Workspace;

//Cast for an IWorkspaceEdit
IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

//Start an edit session and operation
workspaceEdit.StartEditing(true);
workspaceEdit.StartEditOperation();

//Create the Feature Buffer
IFeatureBuffer featureBuffer = featureClass.CreateFeatureBuffer();
//Create insert Feature Cursor using buffering = true.
IFeatureCursor featureCursor = featureClass.Insert(true);

object featureOID;

//With a feature buffer you have the ability to set the attribute for a specific field to be
//the same for all features added to the buffer.
featureBuffer.set_Value(featureBuffer.Fields.FindField( "InstalledBy "), "K Johnston ");

//Here you can set the featurebuffers 's shape by setting the featureBuffer.Shape
//to a geomerty that matched the featureclasses.

//Insert the feature into the feature cursor
featureOID = featureCursor.InsertFeature(featureBuffer);

//Calling flush allows you to handle any errors at a known time rather then on the cursor destruction.
featureCursor.Flush();

//Stop editing
workspaceEdit.StopEditOperation();
workspaceEdit.StopEditing(true);

//Release the Cursor
System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor);
}

  相关解决方案