When i use the code below to add a datarelation to 2 tables named 'Category' and 'Product' and then try to find a row within the tables using the find method shown below I get the error 'Table doesnt have a Primary Key'.
DataRelation catAndProdDataRelation = new DataRelation("CategoryAndProductDataRelation", ds.Tables["Category"].Columns[0]
, ds.Tables["Product"].Columns[3], true);
ds.Relations.Add(catAndProdDataRelation);
DataRow cdr = ds.Tables["Category"].Rows.Find(id);
I have also tried adding the primary keys explicitly with
ds.Tables["Category"].Constraints.Add("PK_ColumnID", ds.Tables["Category"].Columns[0], true);
ds.Tables["Product"].Constraints.Add("PK_ProductID", ds.Tables["Product"].Columns[0], true);
I get the error constraint matches constraint 1 already in collection
I thought the datarelation created the primary keys and the constraint matches error seems to indicate that.
Any help much appreciated