private void FillDropDown(string tableName, string colName) { MapInfo.Mapping.Map map = null; // Get the map if (MapInfo.Engine.Session.Current.MapFactory.Count == 0 || (map = MapInfo.Engine.Session.Current.MapFactory[MapControl1.MapAlias]) == null) { return; } DropDownList1.Items.Clear(); MapInfo.Mapping.FeatureLayer fl = (MapInfo.Mapping.FeatureLayer)map.Layers[tableName]; MapInfo.Data.Table t = fl.Table; MIDataReader tr; MIConnection con = new MIConnection(); MICommand tc = con.CreateCommand(); tc.CommandText = "select " + colName + " from " + t.Alias; con.Open(); tr = tc.ExecuteReader(); while (tr.Read()) { DropDownList1.Items.Add(tr.GetString(0)); } tc.Cancel(); tc.Dispose(); tr.Close(); con.Close(); //t.Close(); }
private void CleanUp() { if (_miCommand != null) { _miCommand.Dispose(); _miCommand = null; } if (_miConnection != null) { _miConnection.Close(); _miConnection = null; } Session.Current.Catalog.CloseAll(); Session.Dispose(); }
private string DetermineRemoteGeomType(FeatureLayer layer) { MapInfo.Data.Table t = layer.Table; MapInfo.Styles.Style style = null; MIConnection con = null; MICommand cmd = null; MIDataReader dr = null; try { con = new MIConnection(); con.Open(); cmd = con.CreateCommand(); cmd.CommandText = "select mi_style from \"" + t.Alias + "\""; cmd.CommandType = System.Data.CommandType.Text; dr = cmd.ExecuteReader(); while (dr.Read()) { if (!dr.IsDBNull(0)) { style = dr.GetStyle(0); break; } } } catch (MIException) { // e.g. if there is no mi_style column } finally { if (cmd != null) { cmd.Dispose(); cmd = null; } if (dr != null) { dr.Close(); } if (con != null) { con.Close(); con = null; } } if (style != null) { if (style is SimpleLineStyle) { return("lclayerline.bmp"); } else if (style is SimpleInterior || style is AreaStyle) { return("lclayerregion.bmp"); } else if (style is BasePointStyle) { return("lclayerpoint.bmp"); } else { return("lclayer.bmp"); } } else { return(null); } }
private void FillDropDown(string tableName, string colName) { MapInfo.Mapping.Map map = null; // Get the map if (MapInfo.Engine.Session.Current.MapFactory.Count == 0 || (map = MapInfo.Engine.Session.Current.MapFactory[MapControl1.MapAlias]) == null) { return; } DropDownList1.Items.Clear(); MapInfo.Mapping.FeatureLayer fl = (MapInfo.Mapping.FeatureLayer)map.Layers[tableName]; MapInfo.Data.Table t = fl.Table; MIDataReader tr; MIConnection con = new MIConnection(); MICommand tc = con.CreateCommand(); tc.CommandText = "select " + colName + " from " + t.Alias ; con.Open(); tr = tc.ExecuteReader() ; while (tr.Read()) { DropDownList1.Items.Add(tr.GetString(0)); } tc.Cancel(); tc.Dispose(); tr.Close() ; con.Close(); //t.Close(); }
private string DetermineRemoteGeomType(FeatureLayer layer) { MapInfo.Data.Table t = layer.Table; MapInfo.Styles.Style style = null; MIConnection con = null; MICommand cmd = null; MIDataReader dr = null; try { con = new MIConnection(); con.Open(); cmd = con.CreateCommand(); cmd.CommandText = "select mi_style from \"" + t.Alias + "\""; cmd.CommandType = System.Data.CommandType.Text; dr = cmd.ExecuteReader(); while (dr.Read()) { if (!dr.IsDBNull(0)) { style = dr.GetStyle(0); break; } } } catch (MIException) { // e.g. if there is no mi_style column } finally { if (cmd != null) { cmd.Dispose(); cmd = null; } if (dr != null) { dr.Close(); } if (con != null) { con.Close(); con = null; } } if (style != null) { if (style is SimpleLineStyle) { return "lclayerline.bmp"; } else if (style is SimpleInterior || style is AreaStyle) { return "lclayerregion.bmp"; } else if (style is BasePointStyle) { return "lclayerpoint.bmp"; } else { return "lclayer.bmp"; } } else { return null; } }