zoukankan      html  css  js  c++  java
  • MapXtreme2005中如何将一个已经存在的表索引化成为一个本地的表?

    003、如何将一个已经存在的表索引化成为一个本地的表???
    ISession session = MapInfo.Engine.Session.Current;

    Table tableToIndex = session.Catalog["DIJISHI"];
    MapInfo.Data.TableInfoNative ti = (MapInfo.Data.TableInfoNative)MapInfo.Data.TableInfoFactory.CreateFromFeatureCollection("NewTable", 
          MapInfo.Data.TableType.Native, tableToIndex);
    ti.Columns["PINYIN"].Indexed = true;
    ti.TablePath = "C:\\NewTable.tab";
    ti.WriteTabFile();

    MapInfo.Data.Table nativetable = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
    nativetable.Close();
    nativetable = MapInfo.Engine.Session.Current.Catalog.OpenTable("C:\\NewTable.tab");

    MapInfo.Data.MIConnection con = new MapInfo.Data.MIConnection();
    con.Open();
    MapInfo.Data.MICommand com = con.CreateCommand();

    com = con.CreateCommand();
    com.CommandText = "Insert into " + nativetable.Alias + " Select * from " + tableToIndex.Alias;

    com.Prepare();
    com.ExecuteNonQuery();

    com.Dispose();
    con.Dispose();
    con.Close();
    注:也可以使用如下的函数来将上述代码进行封装:
    private MapInfo.Data.Table CreateIndexedNativeTableFromExisting(
      MapInfo.Data.Table tableToIndex,
      string columnAliasToIndex,
      string AliasForNewTable,
      string FilePathToSaveNativeTable,
      bool CloseOldTable)

  • 相关阅读:
    web测试学习大纲
    Python语言编程基础
    python文件IO
    Python 正则表达式
    python官网导航翻译
    python常用库
    python连接数据库
    sublime与python交互
    selenium连接浏览器方式
    sublime中运行python时编码格式问题
  • 原文地址:https://www.cnblogs.com/googlegis/p/2978837.html
Copyright © 2011-2022 走看看