我的“增加”代码:
                string code = string.Empty;
                int parentType = 1;
                string parentTypeName = string.Empty;
                int type = 1;
                string typeName = string.Empty;
                int id = 1;
                string name = string.Empty;
                string spec = string.Empty;
                float counts = 0.0F;
                float price = 0.0F;
                float cost = 0.0F;
                string re = string.Empty;
                string formula = string.Empty;
                string reserve01 = string.Empty;
                string reserve02 = string.Empty;
                string reserve03 = string.Empty;
                string groupSort = string.Empty;
                DataTable dt = null;
                DataRow row = null;                int focusedRowHandle = gridView.FocusedRowHandle;
                dt = m_cbhjdReportNEWDataTable;
                code = gridView.GetRowCellValue(focusedRowHandle, "Code").ToString();
                parentType = Convert.ToInt32(gridView.GetRowCellValue(focusedRowHandle, "ParentType"));
               
                typeName = gridView.GetRowCellValue(focusedRowHandle, "TypeName").ToString();
                type = Convert.ToInt32(gridView.GetRowCellValue(focusedRowHandle, "Type"));
                spec = gridView.GetRowCellValue(focusedRowHandle, "Spec").ToString();
                
                string maxID = "select max(ID) from cbhjdReportNEW where Code='" + Utility.ToyCode + "' and Type=" + type;
                id = int.Parse(DAL.Utility.ExeScalar(maxID)) + 1;
                
                groupSort = gridView.GetRowCellValue(focusedRowHandle, "GroupSort").ToString();                row = dt.NewRow();
                row["Code"] = code;
                row["ParentType"] = parentType;
                
                row["Type"] = type;
                row["TypeName"] = typeName;
                row["ID"] = id;
                row["Name"] = "新增" + id.ToString();
                row["Spec"] = spec;
                row["Counts"] = counts;
                row["Price"] = price;
                row["Cost"] = cost;
                row["Re"] = re;
                row["Formula"] = "s*d";
                row["Reserve01"] = reserve01;
                row["Reserve02"] = reserve02;
                row["Reserve03"] = reserve03;
                row["GroupSort"] = groupSort;
                dt.Rows.Add(row);                m_cbhjdReportNEWAdapter.Update(new DataRow[] { row });
                //m_cbjhdReportNNEWDataSet.AcceptChanges();
                //m_cbjhdReportNNEWDataSet.Tables[0].AcceptChanges();
                //m_cbhjdReportNEWDataTable.AcceptChanges();
“删除”代码:
           
                    int focusedRowHandle = gridView.FocusedRowHandle;
                    
                    DataRow row = gridView.GetDataRow(focusedRowHandle);
                    int curType = (int)row["Type"];
                    int curID = (int)row["ID"];
                    row.Delete();
                    //m_cbhjdReportNEWAdapter.UpdateCommand.CommandText = null;
                    m_cbhjdReportNEWAdapter.FillSchema(m_cbjhdReportNNEWDataSet, SchemaType.Mapped);
                    m_cbhjdReportNEWAdapter.Update(new DataRow[] { row });
                    m_cbhjdReportNEWDataTable.AcceptChanges();
                    m_cbjhdReportNNEWDataSet.AcceptChanges();
                    //row.Delete();                    //DataView dvReport = (DataView)gridView.DataSource as DataView;
                    //DataTable dtReport = (DataTable)dvReport.Table;
                    
                    //List<DataRow> rows = Utility.GetUpdatedIDRowsNEw(dtReport, curID, curType);
                    //row.Delete();
                    //rows.Add(row);
                    //m_cbhjdReportNEWAdapter.Update(rows.ToArray());
                    //m_cbhjdReportNEWDataTable.AcceptChanges();
                    //m_cbjhdReportNNEWDataSet.AcceptChanges();
                   // m_cbjhdReportNNEWDataSet.Tables[0].AcceptChanges();                    DataView dvUpdate = new DataView(m_cbhjdReportNEWDataTable);
                                       // DataView dvUpdate = (DataView)gridView.DataSource as DataView;
                    dvUpdate.RowFilter = "Type=" + curType + " and ID>" + curID;
                    int i = 0;
                    foreach (DataRowView drv in dvUpdate)
                    {                        drv["ID"] = curID + i;
                        drv.EndEdit();
                        i++;
                    }
                    // m_cbhjdReportNEWAdapter.FillSchema(m_cbjhdReportNNEWDataSet, SchemaType.Mapped);                   // m_cbhjdReportNEWDataTable.AcceptChanges();
                   // m_cbjhdReportNNEWDataSet.AcceptChanges();                    m_cbhjdReportNEWAdapter.FillSchema(m_cbjhdReportNNEWDataSet, SchemaType.Mapped);
                    m_cbhjdReportNEWAdapter.Update(dvUpdate.Table);
                    m_cbhjdReportNEWDataTable.AcceptChanges();
                    m_cbjhdReportNNEWDataSet.AcceptChanges();
                   
                } 先增加后删除就会出现这个情况:违反并发性: UpdateCommand 影响了预期 1 条记录中的 0 条。  我注释的部分可以看到我用了多少方法  其中还删了不少方法。
    注明:数据表中没有自动增长列
          更新的数据保证主键不会为空  各位哥哥姐姐妹妹弟弟  还有别的高见没 
  这一个bug存在很多地方 把这个问题解决了  我的任务就完成了
  谢谢各位能伸出仗义之手 这个问题三天了还没解决  存在很多地方种