So, I have a DataRelation
as is shown below:
Oraciones1 = new DataRelation("Antecedentes",
dsPubs.Tables["Consecuente"].Columns["Id"],
dsPubs.Tables["Antecedentes"].Columns["Id"]);
dsPubs.Relations.Add(Oraciones1);
where dsPubs
is dsPubs = new DataSet()
and that DataSet has two tables which Both have a data relation. Then; I am iterating over the parents to get the childs, just to get some task done as is shown next:
foreach (DataRow rowAuthor in dsPubs.Tables["Consecuente"].Rows) {
foreach (DataRow rowTitle in rowAuthor.GetChildRows(Oraciones1)) {
}
}
and what I want to do is to remove all the child and the parent from an a specified value which is passed through a function(i.e).
public void function(string value ){
foreach (DataRow rowAuthor in dsPubs.Tables["Consecuente"].Rows){
foreach (DataRow rowTitle in rowAuthor.GetChildRows(Oraciones1){
if(value==rowTitle["id_d"].ToString()){
//remove all the child and the parent from the specified variable "value"
}
}
}
}
I tried to get it done by using rowTitle.Delete() and rowAuthor.Delete() method
but it seemed to not be working, because I think it removes the whole table, and a the time The foreach wanted to continue to grab another value from the table "Consecuente"
it crashed.
Thank you a lot!!