1 private void updateFeatureToolStripMenuItem_Click(object sender, EventArgs e)
2 {
3 try
4 {
5 MapInfo.Data.Table CNTable = MapInfo.Engine.Session.Current.Catalog.GetTable("Testworld");
6 MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("Country='China'");
7 MapInfo.Data.IResultSetFeatureCollection irfc = MapInfo.Engine.Session.Current.Catalog.Search(CNTable, si);
8 Feature ftr = irfc[0];
9 ftr["Country"] = "China";
10 // CNTable.UpdateFeature(ftr);
11 MIConnection conn = new MIConnection();
12 conn.Open();
13 MICommand cmd = conn.CreateCommand();
14 cmd.CommandText = "update " + CNTable.Alias + " set obj=@obj,Country =@name where MI_Key =@MIKEY";
15 cmd.Parameters.Add("@obj", ftr.Geometry);
16 cmd.Parameters.Add("@name", "中国");
17 cmd.Parameters.Add("@MIKEY", ftr.Key);
18 cmd.ExecuteNonQuery();
19
20 //change style
21 MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle();
22 MapInfo.Styles.BitmapPointStyle bmpStyle = new MapInfo.Styles.BitmapPointStyle();
23 bmpStyle.Name = "YIEL2-32.BMP";
24 bmpStyle.PointSize =28;
25 cs.SymbolStyle = bmpStyle;
26
27 }
28 catch (Exception ex)
29 {
30 MessageBox.Show(ex.ToString());
31 }
32 }
2 {
3 try
4 {
5 MapInfo.Data.Table CNTable = MapInfo.Engine.Session.Current.Catalog.GetTable("Testworld");
6 MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("Country='China'");
7 MapInfo.Data.IResultSetFeatureCollection irfc = MapInfo.Engine.Session.Current.Catalog.Search(CNTable, si);
8 Feature ftr = irfc[0];
9 ftr["Country"] = "China";
10 // CNTable.UpdateFeature(ftr);
11 MIConnection conn = new MIConnection();
12 conn.Open();
13 MICommand cmd = conn.CreateCommand();
14 cmd.CommandText = "update " + CNTable.Alias + " set obj=@obj,Country =@name where MI_Key =@MIKEY";
15 cmd.Parameters.Add("@obj", ftr.Geometry);
16 cmd.Parameters.Add("@name", "中国");
17 cmd.Parameters.Add("@MIKEY", ftr.Key);
18 cmd.ExecuteNonQuery();
19
20 //change style
21 MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle();
22 MapInfo.Styles.BitmapPointStyle bmpStyle = new MapInfo.Styles.BitmapPointStyle();
23 bmpStyle.Name = "YIEL2-32.BMP";
24 bmpStyle.PointSize =28;
25 cs.SymbolStyle = bmpStyle;
26
27 }
28 catch (Exception ex)
29 {
30 MessageBox.Show(ex.ToString());
31 }
32 }