iwannafly
路人甲
路人甲
  • 注册日期2005-12-03
  • 发帖数35
  • QQ
  • 铜币274枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:2057回复:4

如何通过sdeworkspacefactory新建featureclass

楼主#
更多 发布于:2006-10-16 16:41
<P>怎么样用ae实现在sde数据库中新建一个featureclass呢?或者说新建一个shapefile然后把它用程序导入到sde数据库中?下面是我的代码,但是有错误,请大家帮忙看一下</P>
<P><BR>   IFeatureWorkspace pFWS;<BR>   IWorkspaceFactory pWorkspaceFactory;<BR>   pWorkspaceFactory=new SdeWorkspaceFactoryClass ();<BR>   IPropertySet pPropSet  = new PropertySetClass();<BR>   pPropSet.SetProperty("SERVER", "ARCGIS");<BR>   //pPropSet.SetProperty("INSTANCE", Instance);<BR>   pPropSet.SetProperty("DATABASE", "sde");<BR>   pPropSet.SetProperty("USER", "sde");<BR>   pPropSet.SetProperty("PASSWORD", "sde");<BR>   pPropSet.SetProperty("VERSION", "sde.DEFAULT");<BR>   pFWS=(IFeatureWorkspace)pWorkspaceFactory1.Open (pPropSet,0);  <BR>   IFields pFields;<BR>   IFieldsEdit pFieldsEdit;<BR>   pFields=new FieldsClass ();<BR>   pFieldsEdit=(IFieldsEdit)pFields;<BR>   IField pField;<BR>   IFieldEdit pFieldEdit;<BR>   pField=new FieldClass ();<BR>   pFieldEdit=(IFieldEdit)pField;<BR>   pFieldEdit.Name_2  ="Shape";<BR>   MessageBox.Show (pFieldEdit.Name.ToString ());// ="Shape";<BR>   pFieldEdit.Type_2 =ESRI.ArcGIS .Geodatabase .esriFieldType .esriFieldTypeGeometry ;<BR>   IGeometryDef pGeomDef;<BR>   IGeometryDefEdit pGeomDefEdit;<BR>   pGeomDef=new GeometryDefClass ();<BR>   pGeomDefEdit=(IGeometryDefEdit)pGeomDef;<BR>   if(sType=="polygon")<BR>   {<BR>    pGeomDefEdit.GeometryType_2 =ESRI.ArcGIS.Geometry .esriGeometryType .esriGeometryPolygon ;<BR>   }<BR>   else if(sType=="point")<BR>   {<BR>    pGeomDefEdit.GeometryType_2 =ESRI.ArcGIS.Geometry .esriGeometryType.esriGeometryPoint  ;<BR>   }<BR>   else if(sType=="line")<BR>   {<BR>    pGeomDefEdit.GeometryType_2 =ESRI.ArcGIS.Geometry .esriGeometryType.esriGeometryPolyline ;<BR>   }<BR>   pGeomDefEdit.SpatialReference_2 =new UnknownCoordinateSystemClass ();<BR>   pFieldEdit.GeometryDef_2 =pGeomDef;<BR>   pFieldsEdit.AddField (pField);<BR>   IField pField1;<BR>   pField1=new FieldClass ();<BR>   IFieldEdit pFieldEdit1;<BR>   pFieldEdit1=(IFieldEdit)pField1;<BR>   pFieldEdit1.Length_2 =30;<BR>   pFieldEdit1.Name_2 ="MiscText";<BR>   pFieldEdit1.Type_2 =ESRI.ArcGIS .Geodatabase .esriFieldType .esriFieldTypeString ;<BR>   pFieldsEdit.AddField(pField1);<BR>   IFeatureClass pFeatClass;<BR>   try<BR>   {<BR>    pFeatClass=pFWS.CreateFeatureClass (sName,pFields,null,null,ESRI.ArcGIS .Geodatabase .esriFeatureType .esriFTSimple,"Shape","");<BR>          <BR>   }<BR>   catch(Exception t)<BR>   {<BR>    MessageBox.Show (t.Message );<BR>   }</P>
<P>错误提示为:</P>
<P>DBMS table not found[Microsoft OLE DB Provider for SQL Server:Deferred prepare could not be completed.对象名'sde.sde.GDB_NetDatasets'无效。][sde.sde.GDB_NetDatasets][STATE_ID=7455]</P>
喜欢0 评分0
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2006-10-17 11:24
数据库版本注册了吗?
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
iwannafly
路人甲
路人甲
  • 注册日期2005-12-03
  • 发帖数35
  • QQ
  • 铜币274枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2006-10-17 15:30
<P>谢谢老大的回复!!!</P>
<P>恕我愚钝,我没怎么明白您的意思!</P>
举报 回复(0) 喜欢(0)     评分
iwannafly
路人甲
路人甲
  • 注册日期2005-12-03
  • 发帖数35
  • QQ
  • 铜币274枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2006-10-17 15:51
哦,注册了。在数据库的SDE.versions表中已经含有DEFAULT行,它的state_id为0
举报 回复(0) 喜欢(0)     评分
zhoujs
路人甲
路人甲
  • 注册日期2004-07-09
  • 发帖数38
  • QQ24938384
  • 铜币276枚
  • 威望0点
  • 贡献值0点
  • 银元0个
4楼#
发布于:2006-11-07 09:28
<P>gis老大,我的代码也和上面的一样,我的数据库也注册了,但是提示:</P>
<P>HRESULT ERROR: 0x8004021 </P>
Sam.Zhou/GIS系统架构师
举报 回复(0) 喜欢(0)     评分
游客

返回顶部