首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 企业软件 > 行业软件 >

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

2012-02-03 
关于调用IFeatureClass进行Insert失败问题 程序简要代码如下:esriGeoDatabase::IFeatureWorkspacePtrspFea

关于调用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);
}

热点排行