MIConnection conection = new MIConnection();
conection.Open();
string strConDB = "server=local;database=guangxi;uid=sa;pwd=sa;DLG=0";
string strSelect = "select * from newplanting";
TableInfoServer ti = new TableInfoServer("newplanting",
"DRIVER={SQL SERVER};" + strConDB,
strSelect, ServerToolkit.Odbc);
ti.CacheSettings.CacheType = CacheOption.On;
MapInfo.Data.Table tabServer;
tabServer = conection.Catalog.OpenTable(ti);
mapControl1.Map.Load(new MapInfo.Mapping.MapTableLoader(tabServer));
conection.Close();
conection.Open();
string strConDB = "server=local;database=guangxi;uid=sa;pwd=sa;DLG=0";
string strSelect = "select * from newplanting";
TableInfoServer ti = new TableInfoServer("newplanting",
"DRIVER={SQL SERVER};" + strConDB,
strSelect, ServerToolkit.Odbc);
ti.CacheSettings.CacheType = CacheOption.On;
MapInfo.Data.Table tabServer;
tabServer = conection.Catalog.OpenTable(ti);
mapControl1.Map.Load(new MapInfo.Mapping.MapTableLoader(tabServer));
conection.Close();
使用MIConnection访问数据库
本文介绍了如何使用MIConnection连接并从指定数据库中读取数据。通过设置连接字符串和SQL查询语句,实现了对TableInfoServer对象的操作,并最终加载到了mapControl1中进行展示。
236

被折叠的 条评论
为什么被折叠?



