DataRelation

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
 
I

Ignacio Machin ( .NET/ C# MVP )

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top