|
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)
|