7、问:如何在一个Web应用中将打开的SpatialWare地图存储成为一个文件?
答:代码如下:
MIConnection Connection =new MIConnection ();
Connection.Open() ;
TableInfoServer tis = new TableInfoServer("usa",
"dsn=sqlserver;UID=sa;PWD=zackary","Select * from usa",MapInfo.Data.ServerToolkit.Odbc );
MapInfo.Data.Table StateCapXY = Connection.Catalog.OpenTable(tis);
mapControl1.Map.Load(new MapTableLoader(StateCapXY ));
MapInfo.Mapping.FeatureLayer lyr=mapControl1.Map.Layers["USA"] as FeatureLayer ;
MapInfo.Data.Table ti = MapInfo.Engine.Session.Current.Catalog.GetTable("usa");
MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchAll();
si.QueryDefinition.SetColumns("*");
MapInfo.Data.IResultSetFeatureCollection irfc = MapInfo.Engine.Session.Current.Catalog.Search(ti.Alias, si);
MapInfo.Data.TableInfoNative tf = (MapInfo.Data.TableInfoNative)MapInfo.Data.TableInfoFactory.CreateFromFeatureCollection("newtab",MapInfo.Data.TableType.Native ,irfc);
foreach(MapInfo.Data.Column cl in tf.Columns)
{
cl.ReadOnly =false;
}
tf.TablePath = "c:\\temp\\newtab.tab";
tf.WriteTabFile ();
MapInfo.Data.Table t = MapInfo.Engine.Session.Current.Catalog.CreateTable (tf);
MapInfo.Engine.Session.Current.Catalog.CloseTable("newtab");
t=MapInfo.Engine.Session.Current.Catalog.OpenTable("c:\\temp\\newtab.tab");
mapControl1.Map.Load(new MapTableLoader(t));
MapInfo.Data.MICommand micomm=new MapInfo.Data.MICommand ("insert into " + t.Alias + " (obj,state,state_name,sw_member) select obj,state,state_name,sw_member from usa", Connection);
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-36378-4.html