Consider a SQL Server table containing:
ID ParentID Text === ========= ============= 1 (null) Product 2 (null) Applications 3 1 Background 4 1 Details 5 2 Mobile
i populate the SqlDataSet table with the table, and now I want to add the parent-child relationship to the DataSet:
public DataRelation( string relationName, DataColumn parentColumn, DataColumn childColumn, bool createConstraints )
Now this guy is using:
DataRelation relation = newDataRelation("ParentChild", ds.Tables[0].Columns["ID"], //parentColumn ds.Tables[0].Columns["ParentID"] //childColumn, true //createConstraints );
But when I do this, I get an exception:
This constraint cannot be enabled as not all values have corresponding parent values.
People suggested passing false for createConstraints ; but then why does he work for him?
What is a child and what is a parent? I would think that the child column is the column that should point to the parent, and the parent column is what the pointer does, which will lead to the opposite relation:
DataRelation relation = newDataRelation("ParentChild", ds.Tables[0].Columns["ParentID"], //parentColumn ds.Tables[0].Columns["ID"], //childColumn true //createConstraints );
So what is this? Why is his work? What except? Why can he create a constraint when he has values?
God, it's hot here.