ARCGIS 开发中遇到错误

1 错误代码:-2147155644

描述:The error number from ArcObjects is: '-2147155644'. The error message from ArcObjects is: {Cannot connect to database because the database client software failed to load. Be sure the database client software is installed and configured correctly.} Please ensure the connection parameters are correct (server=`GIS', instance=`sde:sqlserver:GIS', user=`mapbase', password=`***', database=`GisGeoDbStg', version=`sde.DEFAULT')

在9.3升级到10.2版本中遇到

解决:安装Oracle11g客户端,因为9.3使用的是SDE直连,所以不需要安装Oracle客户端。

2 pFeature.get_Value(i)时一直为null

API中的REMARK,他是这样写的:When this interface is used to access features from a map's feature selection (IMap.FeatureSelection), the IEnumFeatureSetup.AllFields property should be used to return fully hydrated features.也就是说:ArcGIS中FeatureSelection默认的时候只存入Feature 的Shape,而不是整个Feature的字段数据。如果要查看其他数据,必须要进行以下转换才可以。

            IActiveView pActiveView = axMapControl1.ActiveView;

            IMap pMap = axMapControl1.ActiveView.FocusMap;
            if (pMap.SelectionCount == 0) return;
            IEnumFeature pEnumFeature = pMap.FeatureSelection as IEnumFeature;
            IEnumFeatureSetup pEnumFeatureSetup = pEnumFeature as IEnumFeatureSetup;

            pEnumFeatureSetup.AllFields = true;
            IFeature pFeature = pEnumFeature.Next();
            while (pFeature != null)
            {

                       for (int i = 0; i < frmExport.pTableField.Rows.Count; i++)
                        {

                           //如果缺少红色的两行代码,则虽然pFeature不为空,pFeature的fieldcount也是对的,但是 pFeature.get_Value(i)时一直为null,导出属性表很多字段也会为空
                            object strtemp = pFeature.get_Value(i);
                            string str1;
                            if(strtemp!=null)
                            str1 = strtemp.ToString();                           
                        }

            }

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值