I TableAdapter trying to update and add rows in the table via TableAdapter , but throws a DBConcurrencyException "Parallelism violation: UpdateCommand affected 0 of the expected 1 records." What's my mistake?

 //Заполняю таблицу Categories в Dataset GetCategories(); foreach (NorthwindDataSet.CategoriesRow c in northwindDataSet.Categories.Rows) { Console.WriteLine(c.CategoryName + " : " + c.Description); } NorthwindDataSet.CategoriesRow row = northwindDataSet.Categories.NewCategoriesRow(); row.CategoryID = 12; row.CategoryName = "One"; row.Description = "Two"; northwindDataSet.Categories.Rows.Add(row); northwindDataSet.Categories.Rows[1]["CategoryName"] = "Three"; northwindDataSet.Categories.Rows[2]["Description"] = "Four"; CategoriesTableAdapter.Adapter.Update(northwindDataSet.Categories); foreach (NorthwindDataSet.CategoriesRow c in northwindDataSet.Categories.Rows) { Console.WriteLine(c.CategoryName + " : " + c.Description); } Console.ReadKey(); 
  • And how many in categories of records before you add a new one? Does the newly added entry fall under the change in these lines? northwindDataSet.Categories.Rows[1]["CategoryName"] = "Three"; northwindDataSet.Categories.Rows[2]["Description"] = "Four"; - andreycha
  • @andreycha records are only 8, and the new one comes with ID = 12. So I could not inadvertently edit it. - Vladimir

0