private void AddNewGrouFaceDim()//创建一个新的油孔位置信息表 { string sqlcreate = @"CREATE TABLE " + codenumber + "Footprint(ID AUTOINCREMENT,油孔名称 TEXT(50),Dia" + codename + " TEXT(50),X" + codename + " TEXT(50),Y" + codename + " TEXT(50))"; m_connectToAccess.CreateTable(sqlcreate); foreach (DataGridViewRow dr in dataGridViewdim.Rows) { dataGridViewdim.AllowUserToAddRows = false; string sqlupdate1 = "update " + IndexName + " set " + dr.Cells[0].Value.ToString() + "dmax='" + dr.Cells[1].Value.ToString() + "' where 编码 ='" + codename + "'"; if (m_connectToAccess.UpdateInformation(sqlupdate1)) { } ; string sqlupdate2 = "update " + IndexName + " set " + dr.Cells[0].Value.ToString() + "coordX='" + dr.Cells[2].Value.ToString() + "' where 编码 ='" + codename + "'"; if (m_connectToAccess.UpdateInformation(sqlupdate2)) { } ; string sqlupdate3 = "update " + IndexName + " set " + dr.Cells[0].Value.ToString() + "coordY='" + dr.Cells[3].Value.ToString() + "' where 编码 ='" + codename + "'"; if (m_connectToAccess.UpdateInformation(sqlupdate3)) { } ; string sqlinsert = "insert into " + codenumber + "Footprint(油孔名称,Dia" + codename + ",X" + codename + ",Y" + codename + ") values('" + dr.Cells[0].Value.ToString() + "','" + dr.Cells[1].Value.ToString() + "','" + dr.Cells[2].Value.ToString() + "','" + dr.Cells[3].Value.ToString() + "')"; if (m_connectToAccess.InsertInformation(sqlinsert)) { MessageBox.Show("坐标位置信息添加成功"); } } }