DataRelation

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

If I create this DataRelation it works fine
DataRelation orderProductRel = thisDataSet.Relations.Add("OrderProduct",
thisDataSet.Tables["Products"].Columns["ProductID"],
thisDataSet.Tables["Order
Details"].Columns["ProductID"]);

but if I change place on the Products and the Order Details like below I get
runtime error
that says "These columns don't currently have unique values."
DataRelation orderProductRel = thisDataSet.Relations.Add("OrderProduct",
thisDataSet.Tables["Order Details"].Columns["ProductID"],
thisDataSet.Tables["Products"].Columns["ProductID"]);

This sounds strange why is it important to have a specific order when
creating a DataRelation ?

//Tony
 
Hello!

If I create this DataRelation it works fine
DataRelation orderProductRel = thisDataSet.Relations.Add("OrderProduct",
                      thisDataSet.Tables["Products"].Columns["ProductID"],
                      thisDataSet.Tables["Order
Details"].Columns["ProductID"]);

but if I change place on the Products and the Order Details like below I get
runtime error
that says "These columns don't currently have unique values."
DataRelation orderProductRel = thisDataSet.Relations.Add("OrderProduct",
           thisDataSet.Tables["Order Details"].Columns["ProductID"],
           thisDataSet.Tables["Products"].Columns["ProductID"]);

This sounds strange why is it important to have a specific order when
creating a DataRelation ?

//Tony

Take a look at the method description, the first column is the PARENT
and the secnd is the child. That means that from the parent you can
get a LIST of children columns ( by using GetChildrenColumn method ).
That is why the column in the parent column needs to have a unique
value in the corresponding table.
 
Back
Top