There was a problem with the removal of rows from the dataSet associated with the * .mdf database. The connection between them was created automatically in Visual Studio. The database has two tables connected by a key. When you delete the parent table, everything goes fine, but when you delete a child table with the command:

database1DataSet.Products.Rows[currRow2].Delete();

an error is issued:

Deleted row information cannot be accessed through the row.

According to the advice in SO added the line:

database1DataSet.AcceptChanges();

But now another error:

This row has been removed from the table. Data in this row.

It is issued when executing the following code:

 public string Производитель { get { return ((string)(this[this.tableProducts.ПроизводительColumn])); } set { this[this.tableProducts.ПроизводительColumn] = value; } } 

In class

public partial class ProductsRow : global::System.Data.DataRow

designer dataSet.

There are almost no tips to solve it, so I decided to write here. Thank you in advance for your response.

  • I think you need something like a transaction. Those. until you clean up all the tails, the changes in the database will not be finally applied - MaximK

1 answer 1

Error messages make it quite clear that the deleted string is being accessed.

Sample code, as it may occur:

 // Сохранили существующую строку в переменную DataRow row = dataTable.Rows[0]; // Удалили эту строку из DataTable // Но ссылка на неё сохранена в row dataTable.Rows[0].Delete(); // Обратились к удалённой строке // Здесь будет ошибка string temp = row[0].ToString(); 

Look in your code where you are trying to work with already deleted lines.

  • @ahgpoug - There is probably a data binding to controls. Somewhere in them the link to the deleted line keeps. Without seeing all the code, I can’t say anything more. - Alexander Petrov
  • Updated data in the post. - ahgpoug