专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > GIS

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

发布时间:2010-06-06 17:15:15 文章来源:www.iduyao.cn 采编人员:星星草
关于调用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);
}

友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: