C#下mapx与数据库绑定
应该是个老问题了,网上也有一些样例,可是我的程序总是编译不过去,翻了一下手册也没找到原因,麻烦各位帮忙看一下。
private void CreatNewLayerfromDB(string layerName, ADODB.Recordset rsNoPass)
{
MapXLib.Fields flds = new MapXLib.Fields();
// Describe the structure of the Unbound dataset
flds.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.BindLayerClass bindLayerObject = new BindLayerClass();
//MapXLib.BindLayerClass bindLayerObject = axMap1.Layers[1];
bindLayerObject.LayerName = layerName;
bindLayerObject.RefColumn1 = 3;
bindLayerObject.RefColumn2 = 4;
bindLayerObject.LayerType = MapXLib.BindLayerTypeConstants.miBindLayerTypeXY;
MapXLib.Dataset dataSet = axMap1.DataSets.Add(DatasetTypeConstants.miDataSetADO,
rsNoPass, layerName, Type.Missing, Type.Missing, bindLayerObject, flds, false);//运行出错的地方
}
程序在执行axMap1.DataSets.Add()时报错:
Cannot find a specified Field in the DataSet.
麻烦各位指点一下。 --------------------编程问答-------------------- 报错说少了什么特殊字段,是不是类似于Geometry之类的字段没有? --------------------编程问答-------------------- mapx的不知道,到时用过mapxtreme的。
MapInfo.Data.TableInfoAdoNet ti = new MapInfo.Data.TableInfoAdoNet(tableAlies, datatable);
MapInfo.Data.SpatialSchemaXY xy = new MapInfo.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.Table temTable = MapInfo.Engine.Session.Current.Catalog.OpenTable(ti);
currentFeatureLayer = new MapInfo.Mapping.FeatureLayer(temTable, tableAlies);
g.Add(currentFeatureLayer); --------------------编程问答-------------------- 同遇到这个问题!求高人解答
补充:企业软件 , 地理信息系统