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();
northwindDataSet.Categories.Rows[1]["CategoryName"] = "Three"; northwindDataSet.Categories.Rows[2]["Description"] = "Four";
- andreycha