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();
}
}