I have a dataset with two tables and between these tables there is a relation:
DataColumn dc1;
DataColumn dc2;
dc1 = q.Tables[0].Columns["dateFrom"];
dc2 = q.Tables[1].Columns["dateFrom"];
DataRelation dr = new DataRelation("tracker", dc1, dc2, false);
Now I want to remove from the first table all the rows that don’t have a data in the second table. How can I do that?
Why would you do that in the first place? You might lose important data in this case (unless you know it’s unnecessary content).
I assume that if there’s data in the parent table then it must have been added for reason, or there might be a problem in your code. Have a look at that and try to avoid having dirty data.
With regards to your question, I would loop throug the main records and check if there’s any parent records. At the same time compare and make sure the data can be deleted.
Hope it helps.