问题描述
应该是个老问题了,网上也有一些样例,可是我的程序总是编译不过去,翻了一下手册也没找到原因,麻烦各位帮忙看一下。privatevoidCreatNewLayerfromDB(stringlayerName,ADODB.RecordsetrsNoPass){MapXLib.Fieldsflds=newMapXLib.Fields();//DescribethestructureoftheUnbounddatasetflds.Add("Id","Id",AggregationFunctionConstants.miAggregationIndividual,FieldTypeConstants.miTypeInteger);flds.Add("NodeId","NodeId",AggregationFunctionConstants.miAggregationIndividual,FieldTypeConstants.miTypeInteger);flds.Add("X","X",AggregationFunctionConstants.miAggregationSum,FieldTypeConstants.miTypeNumeric);//经度flds.Add("Y","Y",AggregationFunctionConstants.miAggregationSum,FieldTypeConstants.miTypeNumeric);//纬度MapXLib.BindLayerClassbindLayerObject=newBindLayerClass();//MapXLib.BindLayerClassbindLayerObject=axMap1.Layers[1];bindLayerObject.LayerName=layerName;bindLayerObject.RefColumn1=3;bindLayerObject.RefColumn2=4;bindLayerObject.LayerType=MapXLib.BindLayerTypeConstants.miBindLayerTypeXY;MapXLib.DatasetdataSet=axMap1.DataSets.Add(DatasetTypeConstants.miDataSetADO,rsNoPass,layerName,Type.Missing,Type.Missing,bindLayerObject,flds,false);//运行出错的地方}
程序在执行axMap1.DataSets.Add()时报错:CannotfindaspecifiedFieldintheDataSet.麻烦各位指点一下。
解决方案
解决方案二:
报错说少了什么特殊字段,是不是类似于Geometry之类的字段没有?
解决方案三:
mapx的不知道,到时用过mapxtreme的。MapInfo.Data.TableInfoAdoNetti=newMapInfo.Data.TableInfoAdoNet(tableAlies,datatable);MapInfo.Data.SpatialSchemaXYxy=newMapInfo.Data.SpatialSchemaXY();xy.XColumn="X";xy.YColumn="Y";xy.NullPoint="0.0,0.0";xy.StyleType=MapInfo.Data.StyleType.None;xy.CoordSys=MapInfo.Engine.Session.Current.CoordSysFactory.CreateLongLat(MapInfo.Geometry.DatumID.WGS84);ti.SpatialSchema=xy;MapInfo.Data.TabletemTable=MapInfo.Engine.Session.Current.Catalog.OpenTable(ti);currentFeatureLayer=newMapInfo.Mapping.FeatureLayer(temTable,tableAlies);g.Add(currentFeatureLayer);
解决方案四:
同遇到这个问题!求高人解答