mapx连接数据库

MIConnection Connection = new MIConnection();
            Connection.Open();            
            MapInfo.Data.SpatialSchemaXY xy = new MapInfo.Data.SpatialSchemaXY();
            xy.XColumn = "id";
            xy.YColumn = "age";
            xy.NullPoint = "0.0, 0.0";
            xy.StyleType = MapInfo.Data.StyleType.None;
            xy.DefaultStyle = new MapInfo.Styles.CompositeStyle();
            xy.CoordSys = MapInfo.Engine.Session.Current.CoordSysFactory.CreateLongLat(MapInfo.Geometry.DatumID.WGS84);

            //建立TableInfo
            MapInfo.Data.TableInfoServer ti = new MapInfo.Data.TableInfoServer("Customers", "Driver={SQL Server};Server=wingao;Database=mapxdb;Uid=sa;Pwd=1;", "select * from CH_SHENGHUI", MapInfo.Data.ServerToolkit.Odbc);
            ti.SpatialSchema = xy;
            MapInfo.Data.Table miCustomers = MapInfo.Engine.Session.Current.Catalog.OpenTable(ti);
            MapInfo.Mapping.FeatureLayer featureLayer = new MapInfo.Mapping.FeatureLayer(miCustomers);
            mapControl1.Map.Layers.Add(featureLayer);
            mapControl1.Map.SetView(featureLayer);
            Connection.Close();
            MessageBox.Show("OK!");
http://www.cnblogs.com/dachie/archive/2010/08/17/1801598.html
 
  

TableInfoNative tableInfoNative = new TableInfoNative(layerName);
            
    tableInfoNative.TablePath = @"d:\test.tab";
            
    tableInfoNative.Columns.Add(ColumnFactory.CreateFeatureGeometryColumn( MapInfo.Engine.Session.Current.CoordSysFactory.CreateLongLat(MapInfo.Geometry.DatumID.WGS84)));

    tableInfoNative.Columns.Add(ColumnFactory.CreateStyleColumn());

    tableInfoNative.Columns.Add(ColumnFactory.CreateStringColumn("Name", 100));

    tableInfoNative.Columns.Add(ColumnFactory.CreateStringColumn("LineType", 100));
    tableInfoNative.WriteTabFile();

//保存tab

MapInfo.Data.Table t = MapInfo.Engine.Session.Current.Catalog.CreateTable(tableInfoNative);
    MapInfo.Engine.Session.Current.Catalog.CloseTable("test");

//加载到mapControl

Table tb = Session.Current.Catalog.CreateTable(tableInfoNative);

    FeatureLayer tempLayer = new FeatureLayer(tb, layerName);

    mapcontrol.Map.Layers.Add(tempLayer);

  

转载于:https://www.cnblogs.com/bjxly/archive/2012/01/03/2311402.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值