when u use the follow code on 1.1.it will compile without error.
/**////<summary> /// Test table relation. ///</summary> publicvoid Relation_1_1() ...{ DataTable dtParent =this.CreateDataTable(); dtParent.TableName ="Parent"; DataRelation relations = ds.Relations.Add("Relation", dtParent.Columns["index"], dtParent.Columns["parent_index"], false); this.builder.Append(" Get the data from tree ROOT."); this.GetLayerFromParent(ds, relations); this.PrintDataTable(ds.Tables["parent"]); this.builder.Append(" Get the data from tree CHILDS."); this.GetLayerFromChilds(ds, relations); this.PrintDataTable(ds.Tables["parent"]); this.DebugPrint(this.builder.ToString()); }
while it will run error on 2.0 with "Cannot create a DataRelation if Parent or Child Columns are not in a DataSet.".
if u want to run normally,u can use this cod:
/**////<summary> /// Test table relation. ///</summary> publicvoid Relation_2_0() ...{ DataTable dtParent =this.CreateDataTable(); dtParent.TableName ="Parent"; DataSet ds =new DataSet(); ds.Tables.Add(dtParent); DataRelation relations = ds.Relations.Add("Relation", ds.Tables["Parent"].Columns["index"], ds.Tables["Parent"].Columns["parent_index"], false); this.builder.Append(" Get the data from tree ROOT."); this.GetLayerFromParent(ds, relations); this.PrintDataTable(ds.Tables["parent"]); this.builder.Append(" Get the data from tree CHILDS."); this.GetLayerFromChilds(ds, relations); this.PrintDataTable(ds.Tables["parent"]); this.DebugPrint(this.builder.ToString()); //this.WriteToTxtFile(this.builder.ToString()); }