This question has already been answered:
There is a function that removes the user-selected row from the database table, as well as all the rows from the child table that contain the same ID of the parent table. But after restarting the program, the changes are not saved, what could be the problem?
private void buttonDelete_Click(object sender, EventArgs e) { int numRow = bindingSourse.Position; string parentID = null; DataRow selectRow = dataSetDP_DB.Tables[DataSpr.NameTable].Rows[numRow]; foreach (DataColumn prCol in dataSetDP_DB.Tables[DataSpr.NameTable].Columns) { if (prCol.Unique == true) { int numCol = prCol.Ordinal; parentID = selectRow[prCol.Ordinal].ToString(); break; } } DataRow[] delrow = null; foreach (DataRelation relation in dataSetDP_DB.Tables[DataSpr.NameTable].ChildRelations) { int k = 0; foreach (DataColumn chCol in relation.ChildColumns) { foreach (DataRow row in relation.ChildTable.Rows) { if (row[chCol.Ordinal].Equals(parentID)) { row.Delete(); } } } } dataSetDP_DB.Tables[DataSpr.NameTable].Rows.RemoveAt(numRow); tableAdapterManagerSPR.UpdateAll(dataSetDP_DB); }