问题描述
IElementpele=newMarkerElementClass();IPointpp=newPointClass();pp.PutCoords(e.mapX,e.mapY);pele.Geometry=pp;IMarkerElementpme=peleasIMarkerElement;IRgbColorprgb=newRgbColorClass();prgb.Blue=cc.B;prgb.Green=cc.G;prgb.Red=cc.R;psms.Color=prgb;pme.Symbol=psms;pgc.AddElement(pele,0);this.axMapControl1.ActiveView.Refresh();//写入数据库stringscn=@"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=数据表.mdb";OleDbConnectionmycn=newOleDbConnection(scn);mycn.Open();OleDbCommandmycmd=newOleDbCommand();mycmd.Connection=mycn;mycmd.CommandType=CommandType.Text;mycmd.CommandText="select*frompoint1";OleDbDataAdapteradap=newOleDbDataAdapter();adap.SelectCommand=mycmd;DataSetds=newDataSet();adap.Fill(ds,"a");DataTabledt=newDataTable();dt=ds.Tables["a"];strings=DateTime.Now.ToString();intindext=this.comboBox1.SelectedIndex+1;stringid=indext.ToString();intx=Convert.ToInt32(pp.X);stringd="insertintopoint1values('"+id+"',"+x+","+pp.Y+",'"+s+"')";mycmd.CommandText=d;mycmd.ExecuteNonQuery();this.dataGridView1.DataSource=ds.Tables[0];
解决方案
本帖最后由 qq_35202555 于 2016-06-19 14:45:48 编辑
解决方案二:
从数据库查询数据显示到表格中
解决方案三:
变量初始化,读取数据库,写数据